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;
......
......@@ -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);
SharedPreferences.OnSharedPreferenceChangeListener prefListener = (prefs, 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();
}
};
......
......@@ -2,17 +2,15 @@ package srct.whatsopen.views.adapters;
import android.app.Activity;
import android.app.ActivityOptions;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.Typeface;
import android.preference.PreferenceManager;
import android.support.v4.app.ActivityOptionsCompat;
import android.support.v4.content.ContextCompat;
import android.support.v4.util.Pair;
import android.support.v7.widget.RecyclerView;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
......@@ -21,11 +19,6 @@ import android.widget.Filterable;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
......@@ -175,24 +168,25 @@ public class FacilityListAdapter extends
switch(mMode) {
case "All":default:
results = mRealm.where(Facility.class)
.findAllSorted("isOpen", Sort.DESCENDING);
.sort("isOpen", Sort.DESCENDING).findAll();
break;
case "Favorites":
results = mRealm.where(Facility.class)
.equalTo("isFavorited", true)
.findAllSorted("isOpen", Sort.DESCENDING);
.sort("isOpen", Sort.DESCENDING).findAll();
break;
case "Open":
results = mRealm.where(Facility.class)
.equalTo("isOpen", true)
.findAllSorted("isOpen", Sort.DESCENDING);
.sort("isOpen", Sort.DESCENDING).findAll();
break;
case "Closed":
results = mRealm.where(Facility.class)
.equalTo("isOpen", false)
.findAllSorted("isOpen", Sort.DESCENDING);
.sort("isOpen", Sort.DESCENDING).findAll();
break;
}
Log.d("srct.whatsopen", "resetData: " + results);
updateData(results);
}
......
package srct.whatsopen.views.adapters;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import srct.whatsopen.views.fragments.FacilityListFragment;
......
......@@ -3,7 +3,7 @@ package srct.whatsopen.views.decorations;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.support.v7.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
/**
......
......@@ -4,16 +4,22 @@ import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.preference.PreferenceManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import androidx.preference.PreferenceManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import org.jetbrains.annotations.NotNull;
import butterknife.ButterKnife;
import io.realm.Realm;
import io.realm.Sort;
......@@ -25,7 +31,7 @@ import srct.whatsopen.views.decorations.DividerItemDecoration;
import srct.whatsopen.views.adapters.FacilityListAdapter;
public class FacilityListFragment extends android.support.v4.app.Fragment implements MainView {
public class FacilityListFragment extends Fragment implements MainView {
public static final String ARG_MODE = "ARG_MODE";
private String mMode;
......@@ -71,14 +77,18 @@ public class FacilityListFragment extends android.support.v4.app.Fragment implem
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
public void onViewCreated(@NotNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mRecyclerView = ButterKnife.findById(view, R.id.rv_facilities);
mSwipeContainer = ButterKnife.findById(view, R.id.swipe_container);
// mRecyclerView = ButterKnife.findById(view, R.id.rv_facilities);
mRecyclerView = view.findViewById(R.id.rv_facilities);
// mSwipeContainer = ButterKnife.findById(view, R.id.swipe_container);
mSwipeContainer = view.findViewById(R.id.swipe_container);
setUpRecyclerView(view);
Log.d("srct.whatsopen", "#################### we goin bois " + view);
Log.d("srct.whatsopen", "#################### we goin bois " + mRecyclerView);
mSwipeContainer.setOnRefreshListener(() -> mPresenter.loadFacilities());
mSwipeContainer.setOnRefreshListener(mPresenter::loadFacilities);
mSwipeContainer.setColorSchemeColors(getResources().getColor(R.color.colorPrimaryDark));
}
......@@ -86,32 +96,33 @@ public class FacilityListFragment extends android.support.v4.app.Fragment implem
private void setUpRecyclerView(View view) {
mRecyclerView.setLayoutManager(new LinearLayoutManager(view.getContext()));
switch(mMode) {
case "All":default:
switch (mMode) {
case "All":
default:
mRecyclerView.setAdapter(new FacilityListAdapter(view.getContext(),
mRealm.where(Facility.class)
.findAllSortedAsync("isOpen", Sort.DESCENDING),
.sort("isOpen", Sort.DESCENDING).findAllAsync(),
mMode, mRealm, getActivity()));
break;
case "Favorites":
mRecyclerView.setAdapter(new FacilityListAdapter(view.getContext(),
mRealm.where(Facility.class)
.equalTo("isFavorited", true)
.findAllSortedAsync("isOpen", Sort.DESCENDING),
.equalTo("isFavorited", true)
.sort("isOpen", Sort.DESCENDING).findAllAsync(),
mMode, mRealm, getActivity()));
break;
case "Open":
mRecyclerView.setAdapter(new FacilityListAdapter(view.getContext(),
mRealm.where(Facility.class)
.equalTo("isOpen", true)
.findAllSortedAsync("isOpen", Sort.DESCENDING),
.equalTo("isOpen", true)
.sort("isOpen", Sort.DESCENDING).findAllAsync(),
mMode, mRealm, getActivity()));
break;
case "Closed":
mRecyclerView.setAdapter(new FacilityListAdapter(view.getContext(),
mRealm.where(Facility.class)
.equalTo("isOpen", false)
.findAllSortedAsync("isOpen", Sort.DESCENDING),
.equalTo("isOpen", false)
.sort("isOpen", Sort.DESCENDING).findAllAsync(),
mMode, mRealm, getActivity()));
break;
}
......@@ -146,12 +157,9 @@ public class FacilityListFragment extends android.support.v4.app.Fragment implem
// Redraws RecyclerView if the settings have changed for it
private void setPreferenceChangeListener() {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getContext());
mListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if(key.equals("list_view_information_preference")) {
mRecyclerView.getAdapter().notifyDataSetChanged();
}
mListener = (sharedPreferences, key) -> {
if (key.equals("list_view_information_preference")) {
mRecyclerView.getAdapter().notifyDataSetChanged();
}
};
......
......@@ -3,8 +3,8 @@ package srct.whatsopen.views.fragments;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import androidx.annotation.Nullable;
import androidx.fragment.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
......
package srct.whatsopen.views.fragments;
import android.os.Bundle;
import android.support.annotation.Nullable;
import androidx.annotation.Nullable;
import com.takisoft.fix.support.v7.preference.PreferenceFragmentCompat;
......
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/activity_detail"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<include
layout="@layout/toolbar_main"
android:layout_height="wrap_content"
android:layout_width="match_parent"/>
<Button
android:id="@+id/notification_button"