Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
whats-open-android
Commits
26eddbac
Unverified
Commit
26eddbac
authored
Sep 13, 2019
by
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
Changes
30
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
app/build.gradle
View file @
26eddbac
...
...
@@ -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
2
6
buildToolsVersion
'2
7
.0.
3
'
compileSdkVersion
2
9
buildToolsVersion
'2
9
.0.
2
'
defaultConfig
{
applicationId
"srct.whatsopen"
minSdkVersion
16
targetSdkVersion
2
6
minSdkVersion
23
targetSdkVersion
2
9
versionCode
6
versionName
"
1.0.
5"
testInstrumentationRunner
"android
.support
.test.runner.AndroidJUnitRunner"
versionName
'
1.0.
6'
testInstrumentationRunner
"android
x
.test.runner.AndroidJUnitRunner"
}
buildTypes
{
release
{
...
...
@@ -46,33 +47,33 @@ android {
}
dependencies
{
co
mp
i
le
fileTree
(
include:
[
'*.jar'
],
dir:
'libs'
)
androidTest
Co
mp
i
le
(
'com.android.support
.test.espresso:espresso-core:
2.2.2
'
,
{
i
mple
mentation
fileTree
(
include:
[
'*.jar'
],
dir:
'libs'
)
androidTest
I
mple
mentation
(
'androidx
.test.espresso:espresso-core:
3.1.0
'
,
{
exclude
group:
'com.android.support'
,
module:
'support-annotations'
})
co
mp
i
le
'com.astuetz:pagerslidingtabstrip:1.0.1'
co
mp
i
le
'io.realm:android-adapters:2.0.0'
co
mp
i
le
'com.google.code.gson:gson:2.8.
0
'
co
mp
i
le
'com.squareup.retrofit2:retrofit:2.
1.0
'
co
mp
i
le
'com.squareup.retrofit2:adapter-rxjava:2.
0.2
'
co
mp
i
le
'com.squareup.retrofit2:converter-gson:2.
1.0
'
i
mple
mentation
'com.astuetz:pagerslidingtabstrip:1.0.1'
i
mple
mentation
'io.realm:android-adapters:2.0.0'
i
mple
mentation
'com.google.code.gson:gson:2.8.
5
'
i
mple
mentation
'com.squareup.retrofit2:retrofit:2.
6.1
'
i
mple
mentation
'com.squareup.retrofit2:adapter-rxjava:2.
6.1
'
i
mple
mentation
'com.squareup.retrofit2:converter-gson:2.
6.1
'
//noinspection GradleCompatible
co
mp
i
le
'com.android.suppor
t:appcompat
-v7:26
.1.0'
co
mp
i
le
'com.android.support
:cardview
-v7:26.1
.0'
co
mp
i
le
'com.android.support:
support-v4:
26.1
.0'
co
mp
i
le
'com.android.support
:recyclerview
-v7:26.1
.0'
co
mp
i
le
'io.reactivex:rxandroid:1.2.
0
'
co
mp
i
le
'io.reactivex:rxjava:1.
1.4
'
test
Co
mp
i
le
'junit:junit:4.12'
co
mp
i
le
'com.jakewharton:butterknife:
8.8.1
'
kapt
'com.jakewharton:butterknife-compiler:
8.8.1
'
debug
Co
mp
i
le
'com.squareup.leakcanary:leakcanary-android:1.5'
release
Co
mp
i
le
'com.squareup.leakcanary:leakcanary-android-no-op:1.
5
'
test
Co
mp
i
le
'com.squareup.leakcanary:leakcanary-android-no-op:1.
5
'
co
mp
i
le
'com.github.daniel-stoneuk:material-about-library:1.3.0'
co
mp
i
le
'com.takisoft.fix:preference-v7:25.1.1.0'
co
mp
i
le
(
'com.crashlytics.sdk.android:crashlytics:2.6.6@aar'
)
{
transitive
=
true
;
i
mple
mentation
'androidx.appcompa
t:appcompat
:1
.1.0'
i
mple
mentation
'androidx.cardview
:cardview
:1.0
.0'
i
mple
mentation
'androidx.legacy:legacy-
support-v4:
1.0
.0'
i
mple
mentation
'androidx.recyclerview
:recyclerview
:1.0
.0'
i
mple
mentation
'io.reactivex:rxandroid:1.2.
1
'
i
mple
mentation
'io.reactivex:rxjava:1.
3.8
'
test
I
mple
mentation
'junit:junit:4.12'
i
mple
mentation
'com.jakewharton:butterknife:
10.2.0
'
kapt
'com.jakewharton:butterknife-compiler:
10.2.0
'
debug
I
mple
mentation
'com.squareup.leakcanary:leakcanary-android:1.5'
release
I
mple
mentation
'com.squareup.leakcanary:leakcanary-android-no-op:1.
6.3
'
test
I
mple
mentation
'com.squareup.leakcanary:leakcanary-android-no-op:1.
6.3
'
i
mple
mentation
'com.github.daniel-stoneuk:material-about-library:1.3.0'
i
mple
mentation
'com.takisoft.fix:preference-v7:25.1.1.0'
i
mple
mentation
(
'com.crashlytics.sdk.android:crashlytics:2.6.6@aar'
)
{
transitive
=
true
}
co
mp
i
le
"org.jetbrains.kotlin:kotlin-stdlib-j
re7:$kotlin_version
"
i
mple
mentation
"org.jetbrains.kotlin:kotlin-stdlib-j
dk8:1.3.41
"
}
app/src/androidTest/java/srct/whatsopen/ExampleInstrumentedTest.java
View file @
26eddbac
package
srct.whatsopen
;
import
android.content.Context
;
import
android
.support.test
.InstrumentationRegistry
;
import
android
.support.tes
t.runner.AndroidJUnit4
;
import
android
x.test.platform.app
.InstrumentationRegistry
;
import
android
x.test.ext.juni
t.runner
s
.AndroidJUnit4
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
...
...
app/src/main/java/srct/whatsopen/presenters/MainPresenter.java
View file @
26eddbac
...
...
@@ -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
;
}
}
...
...
app/src/main/java/srct/whatsopen/util/NotificationReceiver.java
View file @
26eddbac
...
...
@@ -2,7 +2,7 @@ package srct.whatsopen.util;
import
android.content.Context
;
import
android.content.Intent
;
import
android
.support.v4
.content.WakefulBroadcastReceiver
;
import
android
x.legacy
.content.WakefulBroadcastReceiver
;
public
class
NotificationReceiver
extends
WakefulBroadcastReceiver
{
...
...
app/src/main/java/srct/whatsopen/util/NotificationService.java
View file @
26eddbac
...
...
@@ -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
android
x.core
.app.NotificationCompat
;
import
android
x.legacy
.content.WakefulBroadcastReceiver
;
import
srct.whatsopen.R
;
...
...
app/src/main/java/srct/whatsopen/views/activities/AboutActivity.java
View file @
26eddbac
...
...
@@ -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
android
x
.annotation.Nullable
;
import
com.danielstone.materialaboutlibrary.MaterialAboutActivity
;
import
com.danielstone.materialaboutlibrary.model.MaterialAboutActionItem
;
...
...
app/src/main/java/srct/whatsopen/views/activities/BaseThemeActivity.java
View file @
26eddbac
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
android
x.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
;
...
...
app/src/main/java/srct/whatsopen/views/activities/DetailActivity.java
View file @
26eddbac
...
...
@@ -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
);
...
...
app/src/main/java/srct/whatsopen/views/activities/MainActivity.java
View file @
26eddbac
...
...
@@ -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
android
x.fragment
.app.Fragment
;
import
android
x.viewpager.widget
.ViewPager
;
import
android
x.appcompat
.app.AppCompatActivity
;
import
android
x
.preference.PreferenceManager
;
import
android
x.appcompat
.widget.SearchView
;
import
android
x.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'
...
...
app/src/main/java/srct/whatsopen/views/activities/SettingsActivity.java
View file @
26eddbac
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
);