Compare commits
No commits in common. "master" and "0.9.2-alpha" have entirely different histories.
master
...
0.9.2-alph
@ -10,11 +10,10 @@ android {
|
|||||||
applicationId "com.uam.wmi.findmytutor"
|
applicationId "com.uam.wmi.findmytutor"
|
||||||
minSdkVersion 22
|
minSdkVersion 22
|
||||||
targetSdkVersion 27
|
targetSdkVersion 27
|
||||||
versionCode 66
|
versionCode 1
|
||||||
versionName "1.0.0"
|
versionName "0.9.2-alpha"
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||||
vectorDrawables.useSupportLibrary = true
|
vectorDrawables.useSupportLibrary = true
|
||||||
resConfigs "en", "pl"
|
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
@ -35,11 +34,11 @@ dependencies {
|
|||||||
implementation "ch.acra:acra-http:$acraVersion"
|
implementation "ch.acra:acra-http:$acraVersion"
|
||||||
implementation "ch.acra:acra-toast:$acraVersion"
|
implementation "ch.acra:acra-toast:$acraVersion"
|
||||||
implementation "ch.acra:acra-notification:$acraVersion"
|
implementation "ch.acra:acra-notification:$acraVersion"
|
||||||
implementation "ch.acra:acra-limiter:$acraVersion"
|
|
||||||
|
|
||||||
|
|
||||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||||
implementation 'com.android.support:preference-v7:27.1.1'
|
implementation 'com.android.support:preference-v7:27.1.1'
|
||||||
|
implementation 'com.android.support:appcompat-v7:27.1.1'
|
||||||
implementation 'com.android.support:cardview-v7:27.1.1'
|
implementation 'com.android.support:cardview-v7:27.1.1'
|
||||||
implementation 'com.android.support:design:27.1.1'
|
implementation 'com.android.support:design:27.1.1'
|
||||||
implementation 'com.android.support:support-v4:27.1.1'
|
implementation 'com.android.support:support-v4:27.1.1'
|
||||||
@ -53,8 +52,7 @@ dependencies {
|
|||||||
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
|
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
|
||||||
implementation 'io.swagger:swagger-annotations:1.5.15'
|
implementation 'io.swagger:swagger-annotations:1.5.15'
|
||||||
implementation 'org.threeten:threetenbp:1.3.5'
|
implementation 'org.threeten:threetenbp:1.3.5'
|
||||||
implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:6.7.2'
|
implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:6.6.5'
|
||||||
implementation 'com.mapbox.mapboxsdk:mapbox-sdk-turf:4.0.0'
|
|
||||||
implementation 'io.reactivex.rxjava2:rxjava:2.2.0'
|
implementation 'io.reactivex.rxjava2:rxjava:2.2.0'
|
||||||
implementation 'com.android.support:recyclerview-v7:27.1.1'
|
implementation 'com.android.support:recyclerview-v7:27.1.1'
|
||||||
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
|
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
|
||||||
@ -68,13 +66,8 @@ dependencies {
|
|||||||
implementation 'com.auth0.android:jwtdecode:1.1.1'
|
implementation 'com.auth0.android:jwtdecode:1.1.1'
|
||||||
implementation 'com.annimon:stream:1.2.1'
|
implementation 'com.annimon:stream:1.2.1'
|
||||||
implementation 'com.google.android.gms:play-services-location:16.0.0'
|
implementation 'com.google.android.gms:play-services-location:16.0.0'
|
||||||
|
implementation 'com.mapbox.mapboxsdk:mapbox-sdk-turf:4.0.0'
|
||||||
// FloatingBarMenu
|
// FloatingBarMenu
|
||||||
implementation 'com.getbase:floatingactionbutton:1.10.1'
|
implementation 'com.getbase:floatingactionbutton:1.10.1'
|
||||||
implementation 'org.apache.commons:commons-collections4:4.0'
|
implementation 'org.apache.commons:commons-collections4:4.0'
|
||||||
implementation 'com.android.support:design:27.1.1'
|
|
||||||
|
|
||||||
// spinner loaders library
|
|
||||||
implementation 'com.github.ybq:Android-SpinKit:1.2.0'
|
|
||||||
// rx binding
|
|
||||||
implementation 'com.jakewharton.rxbinding:rxbinding:0.3.0'
|
|
||||||
}
|
}
|
||||||
|
@ -4,10 +4,10 @@
|
|||||||
package="com.uam.wmi.findmytutor">
|
package="com.uam.wmi.findmytutor">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||||
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_COARSE_UPDATES" />
|
<uses-permission android:name="android.permission.ACCESS_COARSE_UPDATES" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
|
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
|
||||||
@ -24,13 +24,10 @@
|
|||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/AppTheme"
|
android:theme="@style/AppTheme"
|
||||||
android:configChanges="locale"
|
|
||||||
tools:ignore="AllowBackup,GoogleAppIndexingWarning">
|
tools:ignore="AllowBackup,GoogleAppIndexingWarning">
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.StartupActivity"
|
android:name=".activity.StartupActivity"
|
||||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
|
||||||
android:launchMode="singleInstance"
|
android:launchMode="singleInstance"
|
||||||
android:screenOrientation="portrait"
|
|
||||||
android:theme="@style/AppTheme.NoActionBar">
|
android:theme="@style/AppTheme.NoActionBar">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
@ -40,21 +37,14 @@
|
|||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.MapActivity"
|
android:name=".activity.MapActivity"
|
||||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
android:launchMode="singleTop" />
|
||||||
android:launchMode="singleTop"
|
|
||||||
android:screenOrientation="portrait"
|
|
||||||
android:windowSoftInputMode="adjustPan" />
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.LoginActivity"
|
android:name=".activity.LoginActivity"
|
||||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
|
||||||
android:excludeFromRecents="true"
|
android:excludeFromRecents="true"
|
||||||
android:launchMode="singleTask"
|
android:launchMode="singleTask"
|
||||||
android:noHistory="true"
|
android:noHistory="true" />
|
||||||
android:screenOrientation="portrait" />
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.SettingsActivity"
|
android:name=".activity.SettingsActivity" />
|
||||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
|
||||||
android:screenOrientation="portrait" />
|
|
||||||
|
|
||||||
<service
|
<service
|
||||||
android:name=".service.BackgroundLocalizationService"
|
android:name=".service.BackgroundLocalizationService"
|
||||||
@ -64,21 +54,7 @@
|
|||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.TutorTab"
|
android:name=".activity.TutorTab"
|
||||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
android:theme="@style/AppTheme"/>
|
||||||
android:windowSoftInputMode="stateHidden|adjustPan"
|
|
||||||
android:screenOrientation="portrait"
|
|
||||||
android:theme="@style/AppTheme" />
|
|
||||||
<activity
|
|
||||||
android:name=".activity.WhiteList"
|
|
||||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
|
||||||
android:screenOrientation="portrait"
|
|
||||||
android:theme="@style/AppTheme" />
|
|
||||||
<activity
|
|
||||||
android:name=".activity.BlackList"
|
|
||||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
|
||||||
android:screenOrientation="portrait"
|
|
||||||
android:theme="@style/AppTheme" />
|
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
@ -1,727 +0,0 @@
|
|||||||
{
|
|
||||||
"features": [
|
|
||||||
{
|
|
||||||
"type": "Feature",
|
|
||||||
"properties": {
|
|
||||||
"name": "Pokoje profesorskie"
|
|
||||||
},
|
|
||||||
"geometry": {
|
|
||||||
"coordinates": [
|
|
||||||
[
|
|
||||||
[
|
|
||||||
16.926707,
|
|
||||||
52.46657
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.92652,
|
|
||||||
52.466244
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926459,
|
|
||||||
52.466255
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926645,
|
|
||||||
52.466582
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926707,
|
|
||||||
52.46657
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"type": "Polygon"
|
|
||||||
},
|
|
||||||
"id": "07f45cd94d45bb5ad0b6b285b0f6fbbb"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "Feature",
|
|
||||||
"properties": {
|
|
||||||
"name": "Skrzydło B"
|
|
||||||
},
|
|
||||||
"geometry": {
|
|
||||||
"coordinates": [
|
|
||||||
[
|
|
||||||
[
|
|
||||||
16.926961,
|
|
||||||
52.467026
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.92677,
|
|
||||||
52.466682
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.92652,
|
|
||||||
52.466244
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926459,
|
|
||||||
52.466255
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926428,
|
|
||||||
52.466203
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926175,
|
|
||||||
52.46625
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.92621,
|
|
||||||
52.466306
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926323,
|
|
||||||
52.466282
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926515,
|
|
||||||
52.466632
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926408,
|
|
||||||
52.466654
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.92644,
|
|
||||||
52.466712
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926543,
|
|
||||||
52.46669
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926754,
|
|
||||||
52.467067
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926961,
|
|
||||||
52.467026
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"type": "Polygon"
|
|
||||||
},
|
|
||||||
"id": "143facf35f322434cfc5776f70f1db36"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "Feature",
|
|
||||||
"properties": {
|
|
||||||
"name": "Winda"
|
|
||||||
},
|
|
||||||
"geometry": {
|
|
||||||
"coordinates": [
|
|
||||||
[
|
|
||||||
[
|
|
||||||
16.92669,
|
|
||||||
52.467141
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.92666,
|
|
||||||
52.467089
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926755,
|
|
||||||
52.46707
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926786,
|
|
||||||
52.467121
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.92669,
|
|
||||||
52.467141
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"type": "Polygon"
|
|
||||||
},
|
|
||||||
"id": "1a35bfafd619b80ffb8b36f03549e9e3"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "Feature",
|
|
||||||
"properties": {
|
|
||||||
"name": "D2"
|
|
||||||
},
|
|
||||||
"geometry": {
|
|
||||||
"coordinates": [
|
|
||||||
[
|
|
||||||
[
|
|
||||||
16.926876,
|
|
||||||
52.466659
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926984,
|
|
||||||
52.466635
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.92694,
|
|
||||||
52.466557
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926831,
|
|
||||||
52.46658
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926876,
|
|
||||||
52.466659
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"type": "Polygon"
|
|
||||||
},
|
|
||||||
"id": "3e0a32a0583254e9e7c47fea1f402472"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "Feature",
|
|
||||||
"properties": {
|
|
||||||
"name": "Sale A"
|
|
||||||
},
|
|
||||||
"geometry": {
|
|
||||||
"coordinates": [
|
|
||||||
[
|
|
||||||
[
|
|
||||||
16.92714,
|
|
||||||
52.466489
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926925,
|
|
||||||
52.466127
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.927027,
|
|
||||||
52.466106
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.927232,
|
|
||||||
52.466472
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.92714,
|
|
||||||
52.466489
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"type": "Polygon"
|
|
||||||
},
|
|
||||||
"id": "3e56cb54baf90049a3ce2f16577c2cd8"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "Feature",
|
|
||||||
"properties": {
|
|
||||||
"name": "D1"
|
|
||||||
},
|
|
||||||
"geometry": {
|
|
||||||
"coordinates": [
|
|
||||||
[
|
|
||||||
[
|
|
||||||
16.926984,
|
|
||||||
52.466635
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.927084,
|
|
||||||
52.466614
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.92704,
|
|
||||||
52.466536
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.92694,
|
|
||||||
52.466557
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926984,
|
|
||||||
52.466635
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"type": "Polygon"
|
|
||||||
},
|
|
||||||
"id": "56c2a7ab4e4d2ac14a46448d523470dc"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "Feature",
|
|
||||||
"properties": {
|
|
||||||
"name": "Hol"
|
|
||||||
},
|
|
||||||
"geometry": {
|
|
||||||
"coordinates": [
|
|
||||||
[
|
|
||||||
[
|
|
||||||
16.927104,
|
|
||||||
52.467081
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.927039,
|
|
||||||
52.467095
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.9268,
|
|
||||||
52.467145
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926754,
|
|
||||||
52.467067
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926961,
|
|
||||||
52.467026
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.927277,
|
|
||||||
52.46696
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.927272,
|
|
||||||
52.466951
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.927451,
|
|
||||||
52.466918
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.927494,
|
|
||||||
52.467002
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.927278,
|
|
||||||
52.467047
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.927144,
|
|
||||||
52.467073
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.927104,
|
|
||||||
52.467081
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"type": "Polygon"
|
|
||||||
},
|
|
||||||
"id": "6f1db27a4df5a46f7a6913556b01effe"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "Feature",
|
|
||||||
"properties": {
|
|
||||||
"name": "Pokoje profesorskie"
|
|
||||||
},
|
|
||||||
"geometry": {
|
|
||||||
"coordinates": [
|
|
||||||
[
|
|
||||||
[
|
|
||||||
16.92677,
|
|
||||||
52.466683
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926961,
|
|
||||||
52.467026
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926887,
|
|
||||||
52.467041
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926695,
|
|
||||||
52.466699
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.92677,
|
|
||||||
52.466683
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"type": "Polygon"
|
|
||||||
},
|
|
||||||
"id": "94f310dcaa6cee75d9e7800bf8d94155"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "Feature",
|
|
||||||
"properties": {
|
|
||||||
"name": "Biblioteka"
|
|
||||||
},
|
|
||||||
"geometry": {
|
|
||||||
"coordinates": [
|
|
||||||
[
|
|
||||||
[
|
|
||||||
16.926801,
|
|
||||||
52.467144
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926971,
|
|
||||||
52.467424
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926956,
|
|
||||||
52.46743
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926944,
|
|
||||||
52.467436
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.92693,
|
|
||||||
52.467441
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926903,
|
|
||||||
52.467452
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926861,
|
|
||||||
52.467464
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926778,
|
|
||||||
52.467476
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926731,
|
|
||||||
52.467485
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926567,
|
|
||||||
52.467194
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926801,
|
|
||||||
52.467144
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"type": "Polygon"
|
|
||||||
},
|
|
||||||
"id": "aadab5775bdeb4eaf82c940255ddadd7"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "Feature",
|
|
||||||
"properties": {
|
|
||||||
"name": "Sale A"
|
|
||||||
},
|
|
||||||
"geometry": {
|
|
||||||
"coordinates": [
|
|
||||||
[
|
|
||||||
[
|
|
||||||
16.927082,
|
|
||||||
52.466492
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926999,
|
|
||||||
52.466509
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926771,
|
|
||||||
52.466109
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926857,
|
|
||||||
52.466088
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.927082,
|
|
||||||
52.466492
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"type": "Polygon"
|
|
||||||
},
|
|
||||||
"id": "b39857ed605e5794fa6c9cdee5d7d6cf"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "Feature",
|
|
||||||
"properties": {
|
|
||||||
"name": "Pokoje profesorskie"
|
|
||||||
},
|
|
||||||
"geometry": {
|
|
||||||
"coordinates": [
|
|
||||||
[
|
|
||||||
[
|
|
||||||
16.926754,
|
|
||||||
52.467066
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926814,
|
|
||||||
52.467054
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926605,
|
|
||||||
52.466676
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926542,
|
|
||||||
52.46669
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926564,
|
|
||||||
52.466728
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926754,
|
|
||||||
52.467066
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"type": "Polygon"
|
|
||||||
},
|
|
||||||
"id": "b754d867fde3826e72fe8c243399ff26"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "Feature",
|
|
||||||
"properties": {
|
|
||||||
"name": "Sale A"
|
|
||||||
},
|
|
||||||
"geometry": {
|
|
||||||
"coordinates": [
|
|
||||||
[
|
|
||||||
[
|
|
||||||
16.927272,
|
|
||||||
52.46695
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.927083,
|
|
||||||
52.466613
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.927167,
|
|
||||||
52.466595
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.92735,
|
|
||||||
52.466936
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.927272,
|
|
||||||
52.46695
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"type": "Polygon"
|
|
||||||
},
|
|
||||||
"id": "c3726b2a2b3a589995fd3f17eecd1f53"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "Feature",
|
|
||||||
"properties": {
|
|
||||||
"name": "D3"
|
|
||||||
},
|
|
||||||
"geometry": {
|
|
||||||
"coordinates": [
|
|
||||||
[
|
|
||||||
[
|
|
||||||
16.92677,
|
|
||||||
52.466682
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926876,
|
|
||||||
52.466659
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926832,
|
|
||||||
52.46658
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926725,
|
|
||||||
52.466604
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.92677,
|
|
||||||
52.466682
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"type": "Polygon"
|
|
||||||
},
|
|
||||||
"id": "c73d9bdbccc15d9907e24b8bb731118a"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "Feature",
|
|
||||||
"properties": {
|
|
||||||
"name": "Pokoje profesorskie"
|
|
||||||
},
|
|
||||||
"geometry": {
|
|
||||||
"coordinates": [
|
|
||||||
[
|
|
||||||
[
|
|
||||||
16.926324,
|
|
||||||
52.466282
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926503,
|
|
||||||
52.46661
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926579,
|
|
||||||
52.466595
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926398,
|
|
||||||
52.466268
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926324,
|
|
||||||
52.466282
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"type": "Polygon"
|
|
||||||
},
|
|
||||||
"id": "d54475cedfa0a866e13933c56bf35d76"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "Feature",
|
|
||||||
"properties": {
|
|
||||||
"name": "Sale A"
|
|
||||||
},
|
|
||||||
"geometry": {
|
|
||||||
"coordinates": [
|
|
||||||
[
|
|
||||||
[
|
|
||||||
16.927607,
|
|
||||||
52.466891
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.92734,
|
|
||||||
52.466562
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.927242,
|
|
||||||
52.466585
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.927451,
|
|
||||||
52.466918
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.927607,
|
|
||||||
52.466891
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"type": "Polygon"
|
|
||||||
},
|
|
||||||
"id": "d97989e446002de50bc8844d2d9cdf5c"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "Feature",
|
|
||||||
"properties": {
|
|
||||||
"name": "Winda"
|
|
||||||
},
|
|
||||||
"geometry": {
|
|
||||||
"coordinates": [
|
|
||||||
[
|
|
||||||
[
|
|
||||||
16.92669,
|
|
||||||
52.467141
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.92666,
|
|
||||||
52.467089
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926755,
|
|
||||||
52.46707
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926786,
|
|
||||||
52.467121
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.92669,
|
|
||||||
52.467141
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"type": "Polygon"
|
|
||||||
},
|
|
||||||
"id": "dfdba4ee1ee0c55193b8dd04f8b00f6c"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "Feature",
|
|
||||||
"properties": {
|
|
||||||
"name": "Skrzydło A"
|
|
||||||
},
|
|
||||||
"geometry": {
|
|
||||||
"coordinates": [
|
|
||||||
[
|
|
||||||
[
|
|
||||||
16.927606,
|
|
||||||
52.466891
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.927339,
|
|
||||||
52.466562
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.927242,
|
|
||||||
52.466585
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.92718,
|
|
||||||
52.466482
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.927232,
|
|
||||||
52.466473
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.927025,
|
|
||||||
52.466105
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926924,
|
|
||||||
52.466126
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926896,
|
|
||||||
52.466078
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.92677,
|
|
||||||
52.466108
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.926998,
|
|
||||||
52.466509
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.927041,
|
|
||||||
52.466537
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.927075,
|
|
||||||
52.466595
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.927082,
|
|
||||||
52.466614
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.927277,
|
|
||||||
52.46696
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.927358,
|
|
||||||
52.466942
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.927354,
|
|
||||||
52.466935
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.92745,
|
|
||||||
52.466918
|
|
||||||
],
|
|
||||||
[
|
|
||||||
16.927606,
|
|
||||||
52.466891
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"type": "Polygon"
|
|
||||||
},
|
|
||||||
"id": "faaa569e3642a741f70a77071f19f131"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"type": "FeatureCollection"
|
|
||||||
}
|
|
@ -5,44 +5,25 @@ import android.content.Context;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
|
|
||||||
import com.uam.wmi.findmytutor.utils.Const;
|
import static org.acra.ReportField.*;
|
||||||
import com.uam.wmi.findmytutor.utils.MapUtils;
|
|
||||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
|
||||||
|
|
||||||
import org.acra.ACRA;
|
import org.acra.ACRA;
|
||||||
import org.acra.annotation.AcraLimiter;
|
|
||||||
import org.acra.annotation.AcraNotification;
|
import org.acra.annotation.AcraNotification;
|
||||||
import org.acra.config.CoreConfigurationBuilder;
|
import org.acra.config.CoreConfigurationBuilder;
|
||||||
import org.acra.config.HttpSenderConfigurationBuilder;
|
import org.acra.config.HttpSenderConfigurationBuilder;
|
||||||
import org.acra.config.ToastConfigurationBuilder;
|
import org.acra.config.ToastConfigurationBuilder;
|
||||||
import org.acra.data.StringFormat;
|
import org.acra.data.StringFormat;
|
||||||
import org.acra.sender.HttpSender;
|
import org.acra.sender.HttpSender;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.acra.ReportField.ANDROID_VERSION;
|
|
||||||
import static org.acra.ReportField.BUILD_CONFIG;
|
|
||||||
import static org.acra.ReportField.CUSTOM_DATA;
|
|
||||||
import static org.acra.ReportField.LOGCAT;
|
|
||||||
import static org.acra.ReportField.PHONE_MODEL;
|
|
||||||
import static org.acra.ReportField.REPORT_ID;
|
|
||||||
import static org.acra.ReportField.SHARED_PREFERENCES;
|
|
||||||
import static org.acra.ReportField.STACK_TRACE;
|
|
||||||
import static org.acra.ReportField.USER_APP_START_DATE;
|
|
||||||
import static org.acra.ReportField.USER_CRASH_DATE;
|
|
||||||
|
|
||||||
|
|
||||||
@AcraNotification(resText = R.string.notification_text,
|
@AcraNotification(resText = R.string.notification_text,
|
||||||
resTitle = R.string.notification_title,
|
resTitle = R.string.notification_title,
|
||||||
resChannelName = R.string.notification_channel)
|
resChannelName = R.string.notification_channel)
|
||||||
@AcraLimiter(failedReportLimit = 2)
|
|
||||||
public class FindMyTutor extends Application {
|
public class FindMyTutor extends Application {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void attachBaseContext(Context base) {
|
protected void attachBaseContext(Context base) {
|
||||||
super.attachBaseContext(base);
|
super.attachBaseContext(base);
|
||||||
//super.attachBaseContext(LocaleHelper.onAttach(base));
|
|
||||||
|
|
||||||
// ACRA core
|
// ACRA core
|
||||||
CoreConfigurationBuilder builder = new CoreConfigurationBuilder(this)
|
CoreConfigurationBuilder builder = new CoreConfigurationBuilder(this)
|
||||||
@ -58,17 +39,16 @@ public class FindMyTutor extends Application {
|
|||||||
ToastConfigurationBuilder.class
|
ToastConfigurationBuilder.class
|
||||||
).setResText(R.string.acra_toast_text);
|
).setResText(R.string.acra_toast_text);
|
||||||
|
|
||||||
|
|
||||||
SharedPreferences sharedPreferences = base.getSharedPreferences("com.uam.wmi.findmytutor_preferences", Context.MODE_PRIVATE);
|
SharedPreferences sharedPreferences = base.getSharedPreferences("com.uam.wmi.findmytutor_preferences", Context.MODE_PRIVATE);
|
||||||
Map header = new HashMap();
|
Map header = new HashMap();
|
||||||
String token = sharedPreferences.getString("API_KEY", "KEY_EMPTY");
|
String token = sharedPreferences.getString("API_KEY", "KEY_EMPTY");
|
||||||
header.put("Authorization", "Bearer " + token);
|
header.put("Authorization","Bearer " + token);
|
||||||
|
|
||||||
// Api POST
|
// Api POST
|
||||||
builder.getPluginConfigurationBuilder(
|
builder.getPluginConfigurationBuilder(
|
||||||
HttpSenderConfigurationBuilder.class
|
HttpSenderConfigurationBuilder.class
|
||||||
// ).setUri("http://192.168.0.15:3000/api/acra")
|
// ).setUri("http://192.168.0.15:3000/api/acra")
|
||||||
).setUri(Const.BASE_URL + "api/Feedback/autoFeedback")
|
).setUri("https://s416084.projektstudencki.pl/develop/api/Feedback/autoFeedback")
|
||||||
.setHttpMethod(HttpSender.Method.POST)
|
.setHttpMethod(HttpSender.Method.POST)
|
||||||
.setHttpHeaders(header)
|
.setHttpHeaders(header)
|
||||||
.setEnabled(true);
|
.setEnabled(true);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.uam.wmi.findmytutor.activity;
|
package com.uam.wmi.findmytutor.activity;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@ -14,8 +13,6 @@ import android.view.MenuInflater;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import com.uam.wmi.findmytutor.utils.LocaleHelper;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link android.preference.PreferenceActivity} which implements and proxies the necessary calls
|
* A {@link android.preference.PreferenceActivity} which implements and proxies the necessary calls
|
||||||
* to be used with AppCompat.
|
* to be used with AppCompat.
|
||||||
|
@ -4,11 +4,9 @@ import android.Manifest;
|
|||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
import android.app.FragmentTransaction;
|
import android.app.FragmentTransaction;
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
@ -22,23 +20,16 @@ import android.support.v7.app.ActionBarDrawerToggle;
|
|||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.support.v7.widget.SearchView;
|
import android.support.v7.widget.SearchView;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.Gravity;
|
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.PopupWindow;
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.uam.wmi.findmytutor.R;
|
import com.uam.wmi.findmytutor.R;
|
||||||
import com.uam.wmi.findmytutor.service.BackgroundLocalizationService;
|
import com.uam.wmi.findmytutor.service.BackgroundLocalizationService;
|
||||||
import com.uam.wmi.findmytutor.utils.ActiveFragment;
|
import com.uam.wmi.findmytutor.utils.ActiveFragment;
|
||||||
import com.uam.wmi.findmytutor.utils.FeedbackUtils;
|
import com.uam.wmi.findmytutor.utils.FeedbackUtils;
|
||||||
import com.uam.wmi.findmytutor.utils.LocaleHelper;
|
|
||||||
import com.uam.wmi.findmytutor.utils.LocaleUtils;
|
|
||||||
import com.uam.wmi.findmytutor.utils.MapUtils;
|
|
||||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||||
import com.uam.wmi.findmytutor.utils.RxSearchObservable;
|
import com.uam.wmi.findmytutor.utils.RxSearchObservable;
|
||||||
|
|
||||||
@ -55,9 +46,7 @@ import io.reactivex.functions.Function;
|
|||||||
import io.reactivex.schedulers.Schedulers;
|
import io.reactivex.schedulers.Schedulers;
|
||||||
|
|
||||||
|
|
||||||
import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext;
|
|
||||||
import static com.uam.wmi.findmytutor.utils.Const.defaultMapZoom;
|
import static com.uam.wmi.findmytutor.utils.Const.defaultMapZoom;
|
||||||
import static com.uam.wmi.findmytutor.utils.Const.onlineBackgroundLocationInterval;
|
|
||||||
import static com.uam.wmi.findmytutor.utils.Const.searchMapZoom;
|
import static com.uam.wmi.findmytutor.utils.Const.searchMapZoom;
|
||||||
import static com.uam.wmi.findmytutor.utils.PrefUtils.storeBackgroundLocationStatus;
|
import static com.uam.wmi.findmytutor.utils.PrefUtils.storeBackgroundLocationStatus;
|
||||||
|
|
||||||
@ -84,36 +73,28 @@ public abstract class BaseActivity
|
|||||||
private SharingFragment sharingFragment;
|
private SharingFragment sharingFragment;
|
||||||
|
|
||||||
private Fragment userListFragment;
|
private Fragment userListFragment;
|
||||||
public ActiveFragment activeFragment = ActiveFragment.NONE;
|
private ActiveFragment activeFragment = ActiveFragment.NONE;
|
||||||
private Fragment activeBottomMenu = null;
|
private Fragment activeBottomMenu = null;
|
||||||
public SearchView searchView;
|
private SearchView searchView;
|
||||||
public MenuItem infoMenuItem;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void attachBaseContext(Context base) {
|
|
||||||
super.attachBaseContext(LocaleHelper.onAttach(base));
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("CheckResult")
|
@SuppressLint("CheckResult")
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(getContentViewId());
|
setContentView(getContentViewId());
|
||||||
|
|
||||||
drawerNavigationView = findViewById(R.id.nav_view);
|
drawerNavigationView = findViewById(R.id.nav_view);
|
||||||
sideDrawer = findViewById(R.id.activity_container);
|
sideDrawer = findViewById(R.id.activity_container);
|
||||||
feedbackUtils = new FeedbackUtils(BaseActivity.this);
|
feedbackUtils = new FeedbackUtils(BaseActivity.this);
|
||||||
|
|
||||||
drawerNavigationView.setNavigationItemSelectedListener(
|
drawerNavigationView.setNavigationItemSelectedListener(
|
||||||
item -> {
|
item -> {
|
||||||
String itemName = (String) item.getTitle();
|
String itemName = (String) item.getTitle();
|
||||||
Intent launchIntent;
|
Intent launchIntent;
|
||||||
if (itemName.equals(getResources().getString(R.string.navigation_item_whitelist))) {
|
if (itemName.equals(getResources().getString(R.string.navigation_item_whitelist))) {
|
||||||
launchIntent = new Intent(getApplicationContext(), WhiteList.class);
|
/* launchIntent = new Intent(getApplicationContext(), WhitelistActivity.class);
|
||||||
startActivity(launchIntent);
|
startActivity(launchIntent);*/
|
||||||
} else if (itemName.equals(getResources().getString(R.string.navigation_item_blacklist))) {
|
} else if (itemName.equals(getResources().getString(R.string.navigation_item_blacklist))) {
|
||||||
launchIntent = new Intent(getApplicationContext(),BlackList.class);
|
/* launchIntent = new Intent(getApplicationContext(), BlacklistActivity.class);
|
||||||
startActivity(launchIntent);
|
startActivity(launchIntent);*/
|
||||||
|
|
||||||
} else if (itemName.equals(getResources().getString(R.string.navigation_item_profile))) {
|
} else if (itemName.equals(getResources().getString(R.string.navigation_item_profile))) {
|
||||||
|
|
||||||
@ -127,9 +108,17 @@ public abstract class BaseActivity
|
|||||||
if(PrefUtils.isBackgroundLocationServiceRunning(getApplicationContext())) {
|
if(PrefUtils.isBackgroundLocationServiceRunning(getApplicationContext())) {
|
||||||
stopBackgroundLocalizationTask();
|
stopBackgroundLocalizationTask();
|
||||||
}
|
}
|
||||||
logout();
|
|
||||||
|
|
||||||
|
storeBackgroundLocationStatus(getApplication(), false);
|
||||||
|
PrefUtils.storeIsLoggedIn(getApplicationContext(), false);
|
||||||
|
|
||||||
|
Intent i = getBaseContext().getPackageManager()
|
||||||
|
.getLaunchIntentForPackage(getBaseContext().getPackageName());
|
||||||
|
if (i != null) {
|
||||||
|
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
|
}
|
||||||
|
startActivity(i);
|
||||||
|
finish();
|
||||||
} else if (itemName.equals(getResources().getString(R.string.navigation_item_feedback))) {
|
} else if (itemName.equals(getResources().getString(R.string.navigation_item_feedback))) {
|
||||||
feedbackUtils.showNoteDialog("FEEDBACK");
|
feedbackUtils.showNoteDialog("FEEDBACK");
|
||||||
|
|
||||||
@ -158,21 +147,6 @@ public abstract class BaseActivity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void logout(){
|
|
||||||
storeBackgroundLocationStatus(getApplication(), false);
|
|
||||||
PrefUtils.storeIsLoggedIn(getApplicationContext(), false);
|
|
||||||
PrefUtils.setBatteryExlusionInfoStatus(getApplicationContext(), true);
|
|
||||||
|
|
||||||
Intent i = getBaseContext().getPackageManager()
|
|
||||||
.getLaunchIntentForPackage(getBaseContext().getPackageName());
|
|
||||||
if (i != null) {
|
|
||||||
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
|
||||||
}
|
|
||||||
startActivity(i);
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void checkPermissions() {
|
protected void checkPermissions() {
|
||||||
final List<String> missingPermissions = new ArrayList<String>();
|
final List<String> missingPermissions = new ArrayList<String>();
|
||||||
|
|
||||||
@ -215,23 +189,17 @@ public abstract class BaseActivity
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void stopBackgroundLocalizationTask() {
|
public void stopBackgroundLocalizationTask() {
|
||||||
PrefUtils.storeEnableSharingLocalization(getApplicationContext(), false);
|
|
||||||
|
|
||||||
Intent stopIntent = new Intent(getApplicationContext(), BackgroundLocalizationService.class);
|
Intent stopIntent = new Intent(getApplicationContext(), BackgroundLocalizationService.class);
|
||||||
stopIntent.putExtra("request_stop", true);
|
stopIntent.putExtra("request_stop", true);
|
||||||
|
startService(stopIntent);
|
||||||
stopService(stopIntent);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startBackgroundLocalizationTask() {
|
public void startBackgroundLocalizationTask() {
|
||||||
checkPermissions();
|
checkPermissions();
|
||||||
PrefUtils.storeEnableSharingLocalization(getApplicationContext(), true);
|
|
||||||
|
|
||||||
Intent startIntent = new Intent(getApplicationContext(), BackgroundLocalizationService.class);
|
Intent startIntent = new Intent(getApplicationContext(), BackgroundLocalizationService.class);
|
||||||
startIntent.putExtra("notify_interval", onlineBackgroundLocationInterval);
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O) {
|
||||||
startForegroundService(startIntent);
|
startForegroundService(startIntent);
|
||||||
} else {
|
} else {
|
||||||
startService(startIntent);
|
startService(startIntent);
|
||||||
@ -285,6 +253,7 @@ public abstract class BaseActivity
|
|||||||
setUpNav();
|
setUpNav();
|
||||||
|
|
||||||
actionBarDrawerToggle.syncState();
|
actionBarDrawerToggle.syncState();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -297,7 +266,6 @@ public abstract class BaseActivity
|
|||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
getMenuInflater().inflate(R.menu.menu_main, menu);
|
getMenuInflater().inflate(R.menu.menu_main, menu);
|
||||||
infoMenuItem = menu.findItem(R.id.action_info);
|
|
||||||
|
|
||||||
MenuItem myActionMenuItem = menu.findItem(R.id.action_search);
|
MenuItem myActionMenuItem = menu.findItem(R.id.action_search);
|
||||||
searchView = (SearchView) myActionMenuItem.getActionView();
|
searchView = (SearchView) myActionMenuItem.getActionView();
|
||||||
@ -308,10 +276,6 @@ public abstract class BaseActivity
|
|||||||
adjustMapToSearch(defaultMapZoom);
|
adjustMapToSearch(defaultMapZoom);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasFocus && activeFragment.equals(ActiveFragment.USER_LIST)) {
|
|
||||||
((UsersListFragment) userListFragment).restoreUsersList();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(hasFocus && activeFragment.equals(ActiveFragment.NONE)){
|
if(hasFocus && activeFragment.equals(ActiveFragment.NONE)){
|
||||||
adjustMapToSearch(searchMapZoom);
|
adjustMapToSearch(searchMapZoom);
|
||||||
}
|
}
|
||||||
@ -320,7 +284,6 @@ public abstract class BaseActivity
|
|||||||
RxSearchObservable.fromView(searchView)
|
RxSearchObservable.fromView(searchView)
|
||||||
.skip(0)
|
.skip(0)
|
||||||
.map(String::toLowerCase)
|
.map(String::toLowerCase)
|
||||||
.filter(t -> !t.isEmpty())
|
|
||||||
.debounce(250, TimeUnit.MILLISECONDS)
|
.debounce(250, TimeUnit.MILLISECONDS)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
@ -350,33 +313,6 @@ public abstract class BaseActivity
|
|||||||
if (actionBarDrawerToggle.onOptionsItemSelected(item)) {
|
if (actionBarDrawerToggle.onOptionsItemSelected(item)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.getItemId()==R.id.action_info){
|
|
||||||
int layoutID;
|
|
||||||
switch (activeFragment){
|
|
||||||
case SHARED_PREFERENCES:
|
|
||||||
layoutID = R.layout.info_popup_sharing_tab;
|
|
||||||
break;
|
|
||||||
case USER_LIST:
|
|
||||||
layoutID = R.layout.info_popup_userlist;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
layoutID = R.layout.info_popup_map;
|
|
||||||
}
|
|
||||||
|
|
||||||
View popupView = getLayoutInflater().inflate(layoutID,null);
|
|
||||||
|
|
||||||
PopupWindow popupWindow = new PopupWindow(popupView,
|
|
||||||
LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
|
|
||||||
// If the PopupWindow should be focusable
|
|
||||||
popupWindow.setFocusable(true);
|
|
||||||
// If you need the PopupWindow to dismiss when when touched outside
|
|
||||||
popupWindow.setBackgroundDrawable(new ColorDrawable());
|
|
||||||
// Get the View's(the one that was clicked in the Fragment) location
|
|
||||||
View anchorView= getWindow().getDecorView().findViewById(android.R.id.content);
|
|
||||||
popupWindow.showAtLocation(anchorView,Gravity.TOP|Gravity.END, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -408,13 +344,10 @@ public abstract class BaseActivity
|
|||||||
removeFragment(sharingFragment);
|
removeFragment(sharingFragment);
|
||||||
removeFragment(userListFragment);
|
removeFragment(userListFragment);
|
||||||
activeFragment = ActiveFragment.NONE;
|
activeFragment = ActiveFragment.NONE;
|
||||||
findViewById(R.id.action_search).setVisibility(View.VISIBLE);
|
|
||||||
} else if (itemId == R.id.nav_profile) {
|
} else if (itemId == R.id.nav_profile) {
|
||||||
loadUserSettingsFragment();
|
loadUserSettingsFragment();
|
||||||
findViewById(R.id.action_search).setVisibility(View.GONE);
|
|
||||||
} else if (itemId == R.id.nav_user_list) {
|
} else if (itemId == R.id.nav_user_list) {
|
||||||
loadUserListFragment();
|
loadUserListFragment();
|
||||||
findViewById(R.id.action_search).setVisibility(View.VISIBLE);
|
|
||||||
}
|
}
|
||||||
selectBottomNavigationBarItem(itemId);
|
selectBottomNavigationBarItem(itemId);
|
||||||
}, 300);
|
}, 300);
|
||||||
@ -427,8 +360,8 @@ public abstract class BaseActivity
|
|||||||
sharingFragment = SharingFragment.newInstance();
|
sharingFragment = SharingFragment.newInstance();
|
||||||
FragmentTransaction ft = getFragmentManager().beginTransaction();
|
FragmentTransaction ft = getFragmentManager().beginTransaction();
|
||||||
ft.replace(R.id.activity_content, sharingFragment);
|
ft.replace(R.id.activity_content, sharingFragment);
|
||||||
//ft.addToBackStack(null);
|
|
||||||
ft.commit();
|
ft.commit();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadUserListFragment() {
|
private void loadUserListFragment() {
|
||||||
@ -437,12 +370,11 @@ public abstract class BaseActivity
|
|||||||
userListFragment = UsersListFragment.newInstance();
|
userListFragment = UsersListFragment.newInstance();
|
||||||
FragmentTransaction ft = getFragmentManager().beginTransaction();
|
FragmentTransaction ft = getFragmentManager().beginTransaction();
|
||||||
ft.replace(R.id.activity_content, userListFragment);
|
ft.replace(R.id.activity_content, userListFragment);
|
||||||
//ft.addToBackStack(null);
|
|
||||||
ft.commit();
|
ft.commit();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateNavigationBarState() {
|
private void updateNavigationBarState() {
|
||||||
int actionId = getNavigationMenuItemId();
|
int actionId = getNavigationMenuItemId();
|
||||||
selectBottomNavigationBarItem(actionId);
|
selectBottomNavigationBarItem(actionId);
|
||||||
}
|
}
|
||||||
@ -454,8 +386,4 @@ public abstract class BaseActivity
|
|||||||
|
|
||||||
abstract int getNavigationMenuItemId();
|
abstract int getNavigationMenuItemId();
|
||||||
abstract int getContentViewId();
|
abstract int getContentViewId();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,370 +0,0 @@
|
|||||||
package com.uam.wmi.findmytutor.activity;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.drawable.ColorDrawable;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.design.widget.CoordinatorLayout;
|
|
||||||
import android.support.design.widget.FloatingActionButton;
|
|
||||||
import android.support.design.widget.Snackbar;
|
|
||||||
import android.support.v7.app.ActionBar;
|
|
||||||
import android.support.v7.app.AlertDialog;
|
|
||||||
import android.support.v7.app.AppCompatActivity;
|
|
||||||
import android.support.v7.widget.DefaultItemAnimator;
|
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
|
||||||
import android.support.v7.widget.RecyclerView;
|
|
||||||
import android.support.v7.widget.Toolbar;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.Gravity;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.CompoundButton;
|
|
||||||
import android.widget.EditText;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.PopupWindow;
|
|
||||||
import android.widget.Switch;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
|
||||||
import android.widget.ToggleButton;
|
|
||||||
|
|
||||||
import com.github.ybq.android.spinkit.SpinKitView;
|
|
||||||
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
|
|
||||||
import com.mapbox.geojson.Point;
|
|
||||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
|
||||||
import com.uam.wmi.findmytutor.R;
|
|
||||||
import com.uam.wmi.findmytutor.adapters.BlackListAdapter;
|
|
||||||
import com.uam.wmi.findmytutor.model.IsUsingListBool;
|
|
||||||
import com.uam.wmi.findmytutor.model.PredefinedCoordViewModel;
|
|
||||||
import com.uam.wmi.findmytutor.model.StudentIdModel;
|
|
||||||
import com.uam.wmi.findmytutor.model.User;
|
|
||||||
import com.uam.wmi.findmytutor.model.UserResponseModel;
|
|
||||||
import com.uam.wmi.findmytutor.network.ApiClient;
|
|
||||||
import com.uam.wmi.findmytutor.service.PredefinedStatusesService;
|
|
||||||
import com.uam.wmi.findmytutor.service.UserService;
|
|
||||||
import com.uam.wmi.findmytutor.utils.LocaleHelper;
|
|
||||||
import com.uam.wmi.findmytutor.utils.MyDividerItemDecoration;
|
|
||||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
|
||||||
import com.uam.wmi.findmytutor.utils.RecyclerTouchListener;
|
|
||||||
import com.uam.wmi.findmytutor.utils.RestApiHelper;
|
|
||||||
import com.uam.wmi.findmytutor.utils.SharingLevel;
|
|
||||||
import com.uam.wmi.findmytutor.utils.WrapContentLinearLayoutManager;
|
|
||||||
|
|
||||||
import java.text.Collator;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import io.reactivex.Observable;
|
|
||||||
import io.reactivex.ObservableSource;
|
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
|
||||||
import io.reactivex.disposables.Disposable;
|
|
||||||
import io.reactivex.functions.Function;
|
|
||||||
import io.reactivex.observers.DisposableObserver;
|
|
||||||
import io.reactivex.observers.DisposableSingleObserver;
|
|
||||||
import io.reactivex.schedulers.Schedulers;
|
|
||||||
import okhttp3.ResponseBody;
|
|
||||||
|
|
||||||
public class BlackList extends AppCompatActivity {
|
|
||||||
|
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
|
||||||
private UserService userService;
|
|
||||||
private boolean didFetched = false;
|
|
||||||
private String tutorId;
|
|
||||||
|
|
||||||
@BindView(R.id.recycler_view_blacklist)
|
|
||||||
RecyclerView recyclerView;
|
|
||||||
@BindView(R.id.black_list_empty_text_view)
|
|
||||||
TextView noNotesView;
|
|
||||||
@BindView(R.id.switch_blacklist_toggle)
|
|
||||||
Switch aSwitch;
|
|
||||||
@BindView(R.id.add_to_black_list_fab)
|
|
||||||
FloatingActionButton addToBlackListFab;
|
|
||||||
@BindView(R.id.loader)
|
|
||||||
SpinKitView loader;
|
|
||||||
|
|
||||||
|
|
||||||
private Integer prevSize;
|
|
||||||
private BlackListAdapter mAdapter;
|
|
||||||
private List<User> blacklistedUsers = new ArrayList<>();
|
|
||||||
private Collator plCollator = Collator.getInstance(Locale.forLanguageTag("pl-PL"));
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void attachBaseContext(Context base) {
|
|
||||||
super.attachBaseContext(LocaleHelper.onAttach(base));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
|
||||||
setContentView(R.layout.activity_black_list);
|
|
||||||
ButterKnife.bind(this);
|
|
||||||
|
|
||||||
tutorId = PrefUtils.getUserId(getApplicationContext());
|
|
||||||
userService = ApiClient.getClient(getApplicationContext())
|
|
||||||
.create(UserService.class);
|
|
||||||
|
|
||||||
if (PrefUtils.isBlackListing(this)){
|
|
||||||
aSwitch.setText(getString(R.string.action_black_list) + " " +getString(R.string.on));
|
|
||||||
aSwitch.setChecked(true);
|
|
||||||
handleChangeRequest(true);
|
|
||||||
}else{
|
|
||||||
aSwitch.setText(getString(R.string.action_black_list) + " " +getString(R.string.off) );
|
|
||||||
aSwitch.setChecked(false);
|
|
||||||
handleChangeRequest(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
|
||||||
toolbar.setTitle(getString(R.string.activity_title_blacklist));
|
|
||||||
setSupportActionBar(toolbar);
|
|
||||||
|
|
||||||
mAdapter = new BlackListAdapter(this, blacklistedUsers);
|
|
||||||
recyclerView.setLayoutManager(new WrapContentLinearLayoutManager(getApplicationContext()));
|
|
||||||
recyclerView.setItemAnimator(new DefaultItemAnimator());
|
|
||||||
recyclerView.addItemDecoration(new MyDividerItemDecoration(this, LinearLayoutManager.VERTICAL, 16));
|
|
||||||
recyclerView.setAdapter(mAdapter);
|
|
||||||
noNotesView.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
fetchBlackListedUsers();
|
|
||||||
/**
|
|
||||||
* On long press on RecyclerView item, open alert dialog
|
|
||||||
* with options to choose
|
|
||||||
* Edit and Delete
|
|
||||||
* */
|
|
||||||
recyclerView.addOnItemTouchListener(new RecyclerTouchListener(this,
|
|
||||||
recyclerView, new RecyclerTouchListener.ClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view, final int position) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onLongClick(View view, int position) {
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
addToBlackListFab.setOnClickListener(this::showFabDialog);
|
|
||||||
handleSwitch();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Observable<List<String>> getListOfBlacklistedUsers(String userId) {
|
|
||||||
return userService.getTutorBlacklistedByID(userId)
|
|
||||||
.toObservable()
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.observeOn(AndroidSchedulers.mainThread());
|
|
||||||
}
|
|
||||||
|
|
||||||
private Observable<User> getUserObservable(String userId) {
|
|
||||||
return userService
|
|
||||||
.getUserById(userId)
|
|
||||||
.toObservable()
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.observeOn(AndroidSchedulers.mainThread());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void fetchBlackListedUsers() {
|
|
||||||
disposable.add(getListOfBlacklistedUsers(tutorId)
|
|
||||||
.doOnSubscribe(this::handleDoOnSubscribe)
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.flatMap(Observable::fromIterable)
|
|
||||||
.flatMap(this::getUserObservable)
|
|
||||||
.subscribe(user -> blacklistedUsers.add(user), this::handleError,this::handleComplete));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleDoOnSubscribe(Disposable disposable) {
|
|
||||||
prevSize = blacklistedUsers.size();
|
|
||||||
blacklistedUsers.clear();
|
|
||||||
didFetched = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleComplete() {
|
|
||||||
Collections.sort(blacklistedUsers, this::sortByUserName);
|
|
||||||
didFetched = true;
|
|
||||||
refreshUI();
|
|
||||||
}
|
|
||||||
private void handleError(Throwable e){
|
|
||||||
showError(e);
|
|
||||||
didFetched = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void refreshUI(){
|
|
||||||
toggleEmptyNotes();
|
|
||||||
mAdapter.notifyItemRangeInserted(prevSize, blacklistedUsers.size() - prevSize);
|
|
||||||
mAdapter.notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
private int sortByUserName(User t1, User t2) {
|
|
||||||
return plCollator.compare(t1.getLastName(), t2.getLastName());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showFabDialog(View v){
|
|
||||||
LayoutInflater layoutInflaterAndroid = LayoutInflater.from(getApplicationContext());
|
|
||||||
@SuppressLint("InflateParams") View view = layoutInflaterAndroid.inflate(R.layout.black_list_fab_modal, null);
|
|
||||||
AlertDialog.Builder alertDialogBuilderUserInput = new android.support.v7.app.AlertDialog.Builder(this);
|
|
||||||
|
|
||||||
alertDialogBuilderUserInput.setView(view).setPositiveButton(getApplicationContext().getString(R.string.modal_location_send), null);
|
|
||||||
|
|
||||||
alertDialogBuilderUserInput
|
|
||||||
.setPositiveButton(R.string.add, null)
|
|
||||||
.setNegativeButton(R.string.cancel, null);
|
|
||||||
|
|
||||||
final AlertDialog alertDialog = alertDialogBuilderUserInput.create();
|
|
||||||
alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
|
|
||||||
|
|
||||||
EditText modalUserInput = view.findViewById(R.id.black_list_modal_input);
|
|
||||||
|
|
||||||
alertDialog.setOnShowListener(dialogInterface -> {
|
|
||||||
Button sendButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
|
|
||||||
|
|
||||||
Button dismissButton = alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE);
|
|
||||||
|
|
||||||
dismissButton.setOnClickListener(view1 -> alertDialog.dismiss());
|
|
||||||
|
|
||||||
sendButton.setOnClickListener(view1 -> {
|
|
||||||
String body = modalUserInput.getText().toString();
|
|
||||||
|
|
||||||
if (TextUtils.isEmpty(body)) {
|
|
||||||
Toast.makeText(getApplicationContext(), R.string.can_not_be_empty, Toast.LENGTH_SHORT).show();
|
|
||||||
modalUserInput.requestFocus();
|
|
||||||
} else {
|
|
||||||
sendUserToBlacklist(body);
|
|
||||||
alertDialog.dismiss();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
alertDialog.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sendUserToBlacklist(String body) {
|
|
||||||
StudentIdModel studentIdModel = new StudentIdModel(body);
|
|
||||||
disposable.add(
|
|
||||||
userService.addStudentToBlacklist(PrefUtils.getUserId(getApplicationContext()), studentIdModel)
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribe(this::handleAddUser,this::showError)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleAddUser(User user) {
|
|
||||||
Toast.makeText(this, R.string.add_user_to_list, Snackbar.LENGTH_LONG).show();
|
|
||||||
blacklistedUsers.clear();
|
|
||||||
fetchBlackListedUsers();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showError(Throwable e) {
|
|
||||||
String message;
|
|
||||||
|
|
||||||
if (e instanceof HttpException) {
|
|
||||||
ResponseBody responseBody = ((HttpException) e).response().errorBody();
|
|
||||||
message = RestApiHelper.getErrorMessage(responseBody);
|
|
||||||
if (((HttpException) e).response().code() == 404) {
|
|
||||||
message = getString(R.string.no_such_a_user);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
message = "Network Error !";
|
|
||||||
}
|
|
||||||
|
|
||||||
Toast.makeText(this, message, Snackbar.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void toggleEmptyNotes() {
|
|
||||||
if (didFetched && blacklistedUsers.size() == 0) {
|
|
||||||
noNotesView.setVisibility(View.VISIBLE);
|
|
||||||
noNotesView.setText(R.string.list_is_empty);
|
|
||||||
loader.setVisibility(View.GONE);
|
|
||||||
}else if (blacklistedUsers.size() > 0) {
|
|
||||||
noNotesView.setVisibility(View.GONE);
|
|
||||||
loader.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
loader.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
|
||||||
// Inflate the menu; this adds items to the action bar if it is present.
|
|
||||||
getMenuInflater().inflate(R.menu.menu_black_list, menu);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
|
|
||||||
if (item.getItemId()==R.id.action_blacklist_info_popup){
|
|
||||||
int layoutID = R.layout.info_popup_blacklist;
|
|
||||||
|
|
||||||
View popupView = getLayoutInflater().inflate(layoutID,null);
|
|
||||||
|
|
||||||
PopupWindow popupWindow = new PopupWindow(popupView,
|
|
||||||
LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
|
|
||||||
// If the PopupWindow should be focusable
|
|
||||||
popupWindow.setFocusable(true);
|
|
||||||
// If you need the PopupWindow to dismiss when when touched outside
|
|
||||||
popupWindow.setBackgroundDrawable(new ColorDrawable());
|
|
||||||
// Get the View's(the one that was clicked in the Fragment) location
|
|
||||||
View anchorView= getWindow().getDecorView().findViewById(android.R.id.content);
|
|
||||||
popupWindow.showAtLocation(anchorView,Gravity.TOP|Gravity.END, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.onOptionsItemSelected(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleSwitch(){
|
|
||||||
aSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
|
||||||
if (isChecked){
|
|
||||||
aSwitch.setText(getString(R.string.action_black_list) + " "+ getString(R.string.on));
|
|
||||||
handleChangeRequest(true);
|
|
||||||
PrefUtils.useBlacklist(this,true);
|
|
||||||
}else {
|
|
||||||
aSwitch.setText(getString(R.string.action_black_list) + " "+getString(R.string.off));
|
|
||||||
handleChangeRequest(false);
|
|
||||||
PrefUtils.useBlacklist(this,false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleChangeRequest(boolean value){
|
|
||||||
IsUsingListBool isUsingListBool = new IsUsingListBool();
|
|
||||||
isUsingListBool.setIsUsing(value);
|
|
||||||
disposable.add(
|
|
||||||
userService.setTutorBlacklist(tutorId, isUsingListBool)
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribe(()->{
|
|
||||||
},this::showError)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPause() {
|
|
||||||
super.onPause();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStop() {
|
|
||||||
super.onStop();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDestroy() {
|
|
||||||
super.onDestroy();
|
|
||||||
disposable.dispose();
|
|
||||||
}
|
|
||||||
}
|
|
@ -21,13 +21,11 @@ import com.auth0.android.jwt.JWT;
|
|||||||
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
|
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
|
||||||
import com.uam.wmi.findmytutor.R;
|
import com.uam.wmi.findmytutor.R;
|
||||||
import com.uam.wmi.findmytutor.model.JwtToken;
|
import com.uam.wmi.findmytutor.model.JwtToken;
|
||||||
import com.uam.wmi.findmytutor.model.LdapUser;
|
|
||||||
import com.uam.wmi.findmytutor.model.User;
|
import com.uam.wmi.findmytutor.model.User;
|
||||||
import com.uam.wmi.findmytutor.model.ValidateUser;
|
import com.uam.wmi.findmytutor.model.ValidateUser;
|
||||||
import com.uam.wmi.findmytutor.network.ApiClient;
|
import com.uam.wmi.findmytutor.network.ApiClient;
|
||||||
import com.uam.wmi.findmytutor.service.LdapService;
|
import com.uam.wmi.findmytutor.service.LdapService;
|
||||||
import com.uam.wmi.findmytutor.service.UserService;
|
import com.uam.wmi.findmytutor.service.UserService;
|
||||||
import com.uam.wmi.findmytutor.utils.MapUtils;
|
|
||||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||||
import com.uam.wmi.findmytutor.utils.RestApiHelper;
|
import com.uam.wmi.findmytutor.utils.RestApiHelper;
|
||||||
|
|
||||||
@ -150,9 +148,8 @@ public class LoginActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
private void loginProcess(String email, String password) {
|
private void loginProcess(String email, String password) {
|
||||||
ValidateUser user = new ValidateUser(email, password);
|
ValidateUser user = new ValidateUser(email, password);
|
||||||
// LdapUser fakeUser = new LdapUser(email, password,"wmi","tutor",email,"Fałszywy",email);
|
|
||||||
disposable.add(ldapService.validate(user)
|
disposable.add(ldapService.validate(user)
|
||||||
//disposable.add(ldapService.fakeValidate(fakeUser)
|
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(this::handleResponse, this::handleError));
|
.subscribe(this::handleResponse, this::handleError));
|
||||||
@ -191,7 +188,6 @@ public class LoginActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
getUserProfile(userId.asString());
|
getUserProfile(userId.asString());
|
||||||
|
|
||||||
|
|
||||||
Intent data = new Intent();
|
Intent data = new Intent();
|
||||||
String txt = "Main Activity";
|
String txt = "Main Activity";
|
||||||
data.setData(Uri.parse(txt));
|
data.setData(Uri.parse(txt));
|
||||||
|
@ -4,11 +4,9 @@ import android.Manifest;
|
|||||||
import android.animation.ObjectAnimator;
|
import android.animation.ObjectAnimator;
|
||||||
import android.animation.ValueAnimator;
|
import android.animation.ValueAnimator;
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.PowerManager;
|
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
@ -46,12 +44,9 @@ import com.uam.wmi.findmytutor.model.PredefinedCoordViewModel;
|
|||||||
import com.uam.wmi.findmytutor.model.User;
|
import com.uam.wmi.findmytutor.model.User;
|
||||||
import com.uam.wmi.findmytutor.network.ApiClient;
|
import com.uam.wmi.findmytutor.network.ApiClient;
|
||||||
import com.uam.wmi.findmytutor.service.CoordinateService;
|
import com.uam.wmi.findmytutor.service.CoordinateService;
|
||||||
import com.uam.wmi.findmytutor.service.PredefinedCoordinatesService;
|
import com.uam.wmi.findmytutor.service.PredefinedStatusesService;
|
||||||
import com.uam.wmi.findmytutor.service.UserService;
|
import com.uam.wmi.findmytutor.service.UserService;
|
||||||
import com.uam.wmi.findmytutor.utils.ApproximatedLocalization;
|
import com.uam.wmi.findmytutor.utils.ApproximatedLocalization;
|
||||||
import com.uam.wmi.findmytutor.utils.EnableSharingDialog;
|
|
||||||
import com.uam.wmi.findmytutor.utils.LocaleHelper;
|
|
||||||
import com.uam.wmi.findmytutor.utils.LocaleUtils;
|
|
||||||
import com.uam.wmi.findmytutor.utils.ManualLocationUtils;
|
import com.uam.wmi.findmytutor.utils.ManualLocationUtils;
|
||||||
import com.uam.wmi.findmytutor.utils.MapMarker;
|
import com.uam.wmi.findmytutor.utils.MapMarker;
|
||||||
import com.uam.wmi.findmytutor.utils.MapUtils;
|
import com.uam.wmi.findmytutor.utils.MapUtils;
|
||||||
@ -72,19 +67,17 @@ import io.reactivex.schedulers.Schedulers;
|
|||||||
import okhttp3.ResponseBody;
|
import okhttp3.ResponseBody;
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
||||||
import static com.uam.wmi.findmytutor.utils.Const.mapRefreshInterval;
|
|
||||||
|
|
||||||
public class MapActivity extends BaseActivity
|
public class MapActivity extends BaseActivity
|
||||||
implements PermissionsListener, OnMapReadyCallback {
|
implements PermissionsListener, OnMapReadyCallback {
|
||||||
|
|
||||||
private HashMap<Long, String> markerUserHash = new HashMap<>();
|
|
||||||
private String tag = getClass().getName();
|
private String tag = getClass().getName();
|
||||||
private PermissionsManager permissionsManager;
|
private PermissionsManager permissionsManager;
|
||||||
private LocationComponent locationComponent;
|
private LocationComponent locationComponent;
|
||||||
private CoordinateService coordinateService;
|
private CoordinateService coordinateService;
|
||||||
private UserService userService;
|
private UserService userService;
|
||||||
|
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
private int mInterval = mapRefreshInterval;
|
private int mInterval = 10000;
|
||||||
private Handler mHandler = new Handler();
|
private Handler mHandler = new Handler();
|
||||||
private Runnable mStatusChecker;
|
private Runnable mStatusChecker;
|
||||||
private MapView mapView;
|
private MapView mapView;
|
||||||
@ -93,8 +86,9 @@ public class MapActivity extends BaseActivity
|
|||||||
private Button removeLocationButton;
|
private Button removeLocationButton;
|
||||||
private Marker tmpLocalMarker;
|
private Marker tmpLocalMarker;
|
||||||
private Coordinate droppedMarkercoordinate;
|
private Coordinate droppedMarkercoordinate;
|
||||||
public HashMap<String, Coordinate> coordsMap = new HashMap<>();
|
private HashMap<String, Coordinate> coordsMap = new HashMap<>();
|
||||||
private HashMap<String, MapMarker> markerHash = new HashMap<>();
|
private HashMap<String, MapMarker> markerHash = new HashMap<>();
|
||||||
|
private HashMap<Long, String> markerUserHash = new HashMap<>();
|
||||||
private Set<String> previousCoordsIds = new HashSet<>();
|
private Set<String> previousCoordsIds = new HashSet<>();
|
||||||
private ManualLocationUtils manualLocationUtils;
|
private ManualLocationUtils manualLocationUtils;
|
||||||
// Camera Animation params
|
// Camera Animation params
|
||||||
@ -106,15 +100,9 @@ public class MapActivity extends BaseActivity
|
|||||||
private ApproximatedLocalization approximatedLocalization;
|
private ApproximatedLocalization approximatedLocalization;
|
||||||
private boolean shouldFetchNewCoords = true;
|
private boolean shouldFetchNewCoords = true;
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void attachBaseContext(Context base) {
|
|
||||||
super.attachBaseContext(LocaleHelper.onAttach(base));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
isTutor = PrefUtils.getIsTutor(this);
|
isTutor = PrefUtils.getIsTutor(this);
|
||||||
myId = PrefUtils.getUserId(getApplicationContext());
|
myId = PrefUtils.getUserId(getApplicationContext());
|
||||||
|
|
||||||
@ -127,7 +115,6 @@ public class MapActivity extends BaseActivity
|
|||||||
mStatusChecker = () -> {
|
mStatusChecker = () -> {
|
||||||
try {
|
try {
|
||||||
if (shouldFetchNewCoords) {
|
if (shouldFetchNewCoords) {
|
||||||
checkIfUsesCanBeTutor();
|
|
||||||
fetchTopCoords();
|
fetchTopCoords();
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
@ -136,8 +123,10 @@ public class MapActivity extends BaseActivity
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
selectLocationButton = findViewById(R.id.select_location_button);
|
selectLocationButton = findViewById(R.id.select_location_button);
|
||||||
removeLocationButton = findViewById(R.id.remove_location_button);
|
removeLocationButton = findViewById(R.id.remove_location_button);
|
||||||
|
Mapbox.getInstance(this, getString(R.string.access_token));
|
||||||
mapView = findViewById(R.id.mapView);
|
mapView = findViewById(R.id.mapView);
|
||||||
mapView.onCreate(savedInstanceState);
|
mapView.onCreate(savedInstanceState);
|
||||||
mapView.getMapAsync(this);
|
mapView.getMapAsync(this);
|
||||||
@ -146,11 +135,6 @@ public class MapActivity extends BaseActivity
|
|||||||
handleBackgroundTaskLifeCycle();
|
handleBackgroundTaskLifeCycle();
|
||||||
manualLocationUtils = new ManualLocationUtils(MapActivity.this);
|
manualLocationUtils = new ManualLocationUtils(MapActivity.this);
|
||||||
approximatedLocalization = new ApproximatedLocalization(MapUtils.loadJsonFromAsset(getApplicationContext(), "building.geojson"));
|
approximatedLocalization = new ApproximatedLocalization(MapUtils.loadJsonFromAsset(getApplicationContext(), "building.geojson"));
|
||||||
|
|
||||||
if(isTutor){
|
|
||||||
MapUtils.BatteryOptimizationsExceptionCheck(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -161,7 +145,22 @@ public class MapActivity extends BaseActivity
|
|||||||
|
|
||||||
mapboxMap.setOnMarkerClickListener(marker -> {
|
mapboxMap.setOnMarkerClickListener(marker -> {
|
||||||
String id = markerUserHash.get(marker.getId());
|
String id = markerUserHash.get(marker.getId());
|
||||||
createMarkerModal(id);
|
String locationLevel = PrefUtils.getLocationLevel(getApplicationContext());
|
||||||
|
|
||||||
|
if (id.equals(myId) && (locationLevel.equals(SharingLevel.MANUAL.toString()) || locationLevel.equals(SharingLevel.PREDEFINED.toString()))) {
|
||||||
|
selectLocationButton.setVisibility(View.GONE);
|
||||||
|
removeLocationButton.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
removeLocationButton.setOnClickListener(view -> {
|
||||||
|
stopBackgroundLocalizationTask();
|
||||||
|
|
||||||
|
removeLocationButton.setVisibility(View.GONE);
|
||||||
|
Toast.makeText(MapActivity.this, R.string.manual_marker_info, Toast.LENGTH_SHORT).show();
|
||||||
|
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
createMarkerModal(id);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
@ -213,34 +212,14 @@ public class MapActivity extends BaseActivity
|
|||||||
TextView sharingLevelView = view.findViewById(R.id.sharing_level);
|
TextView sharingLevelView = view.findViewById(R.id.sharing_level);
|
||||||
|
|
||||||
userName.setText(String.format("%s %s", user.getFirstName(), user.getLastName()));
|
userName.setText(String.format("%s %s", user.getFirstName(), user.getLastName()));
|
||||||
|
status.setText(String.format("%s: %s", getResources().getString(R.string.status_switch_title), cordStatus));
|
||||||
if (cordStatus.equals("")) {
|
sharingLevelView.setText(String.format("%s: %s", getResources().getString(R.string.settings_location_level), sharingLevel));
|
||||||
status.setText(String.format("%s: %s", getResources().getString(R.string.status_switch_title), getString(R.string.lack_of_status)));
|
|
||||||
} else {
|
|
||||||
status.setText(String.format("%s: %s", getResources().getString(R.string.status_switch_title), cordStatus));
|
|
||||||
}
|
|
||||||
|
|
||||||
String sharingLevelToRender = sharingLevel;
|
|
||||||
Log.e("LOCALE",PrefUtils.getLocale(getApplicationContext()));
|
|
||||||
|
|
||||||
if (PrefUtils.getLocale(getApplicationContext()).equals("pl") ||
|
|
||||||
PrefUtils.getLocale(getApplicationContext()).equals("pl-PL") ||
|
|
||||||
PrefUtils.getLocale(getApplicationContext()).equals("[pl-PL]")) {
|
|
||||||
if (sharingLevel.equals(SharingLevel.MANUAL.toString())) {
|
|
||||||
sharingLevelToRender = getString(R.string.manual_mode);
|
|
||||||
} else if (sharingLevel.equals(SharingLevel.EXACT.toString())) {
|
|
||||||
sharingLevelToRender = getString(R.string.exact_mode);
|
|
||||||
} else if (sharingLevel.equals(SharingLevel.APPROXIMATED.toString())) {
|
|
||||||
sharingLevelToRender = getString(R.string.approx_mode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sharingLevelView.setText(String.format("%s: %s", getResources().getString(R.string.settings_location_level), sharingLevelToRender));
|
|
||||||
|
|
||||||
final AlertDialog alertDialog = alertDialogBuilderUserInput.create();
|
final AlertDialog alertDialog = alertDialogBuilderUserInput.create();
|
||||||
alertDialog.show();
|
alertDialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void handleError(Throwable error) {
|
private void handleError(Throwable error) {
|
||||||
showError(error);
|
showError(error);
|
||||||
}
|
}
|
||||||
@ -248,6 +227,8 @@ Log.e("LOCALE",PrefUtils.getLocale(getApplicationContext()));
|
|||||||
private void showError(Throwable e) {
|
private void showError(Throwable e) {
|
||||||
String message;
|
String message;
|
||||||
|
|
||||||
|
Log.e("ERR", e.toString());
|
||||||
|
|
||||||
if (e instanceof HttpException) {
|
if (e instanceof HttpException) {
|
||||||
ResponseBody responseBody = ((HttpException) e).response().errorBody();
|
ResponseBody responseBody = ((HttpException) e).response().errorBody();
|
||||||
message = RestApiHelper.getErrorMessage(responseBody);
|
message = RestApiHelper.getErrorMessage(responseBody);
|
||||||
@ -259,12 +240,7 @@ Log.e("LOCALE",PrefUtils.getLocale(getApplicationContext()));
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setOnMapClickListener() {
|
private void setOnMapClickListener() {
|
||||||
|
mapboxMap.addOnMapClickListener(e -> removeLocationButton.setVisibility(View.GONE));
|
||||||
mapboxMap.addOnMapClickListener(e -> {
|
|
||||||
removeLocationButton.setVisibility(View.GONE);
|
|
||||||
selectLocationButton.setVisibility(View.GONE);
|
|
||||||
restoreMapMarkers();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setOnMapLongClickListener() {
|
private void setOnMapLongClickListener() {
|
||||||
@ -307,11 +283,6 @@ Log.e("LOCALE",PrefUtils.getLocale(getApplicationContext()));
|
|||||||
PrefUtils.getLocationLevel(getApplicationContext())
|
PrefUtils.getLocationLevel(getApplicationContext())
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!PrefUtils.isEnableSharingLocalization(getApplicationContext())) {
|
|
||||||
EnableSharingDialog sharingDialog = new EnableSharingDialog();
|
|
||||||
sharingDialog.show(getFragmentManager(), "Sharing");
|
|
||||||
}
|
|
||||||
|
|
||||||
PrefUtils.putManualLocation(this, latLng, approximatedLocation);
|
PrefUtils.putManualLocation(this, latLng, approximatedLocation);
|
||||||
|
|
||||||
handleBackgroundTaskLifeCycle();
|
handleBackgroundTaskLifeCycle();
|
||||||
@ -351,18 +322,14 @@ Log.e("LOCALE",PrefUtils.getLocale(getApplicationContext()));
|
|||||||
|
|
||||||
final AlertDialog alertDialog = alertDialogBuilderUserInput.create();
|
final AlertDialog alertDialog = alertDialogBuilderUserInput.create();
|
||||||
|
|
||||||
EditText modalUserInput = view.findViewById(R.id.manual_input);
|
EditText modalUserInput = view.findViewById(R.id.feedback_input);
|
||||||
|
|
||||||
alertDialog.setOnShowListener(dialogInterface -> {
|
alertDialog.setOnShowListener(dialogInterface -> {
|
||||||
Button sendButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
|
Button sendButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
|
||||||
|
|
||||||
Button dismissButton = alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE);
|
Button dismissButton = alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE);
|
||||||
|
|
||||||
dismissButton.setOnClickListener(view1 -> {
|
dismissButton.setOnClickListener(view1 -> alertDialog.dismiss());
|
||||||
PrefUtils.putCurrentManualLocationName(getApplicationContext(), getString(R.string.other_location));
|
|
||||||
PrefUtils.putCurrentManualLocation(getApplicationContext(), "-1");
|
|
||||||
|
|
||||||
alertDialog.dismiss();
|
|
||||||
});
|
|
||||||
|
|
||||||
sendButton.setOnClickListener(view1 -> {
|
sendButton.setOnClickListener(view1 -> {
|
||||||
String body = modalUserInput.getText().toString();
|
String body = modalUserInput.getText().toString();
|
||||||
@ -372,7 +339,6 @@ Log.e("LOCALE",PrefUtils.getLocale(getApplicationContext()));
|
|||||||
modalUserInput.requestFocus();
|
modalUserInput.requestFocus();
|
||||||
} else {
|
} else {
|
||||||
sendLocation(body, latLng);
|
sendLocation(body, latLng);
|
||||||
PrefUtils.putCurrentManualLocationName(getApplicationContext(), body);
|
|
||||||
alertDialog.dismiss();
|
alertDialog.dismiss();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -383,7 +349,7 @@ Log.e("LOCALE",PrefUtils.getLocale(getApplicationContext()));
|
|||||||
|
|
||||||
|
|
||||||
private void sendLocation(String body, LatLng latLng) {
|
private void sendLocation(String body, LatLng latLng) {
|
||||||
PredefinedCoordinatesService predefinedCoordinatesService = ApiClient.getClient(getApplicationContext()).create(PredefinedCoordinatesService.class);
|
PredefinedStatusesService predefinedStatusesService = ApiClient.getClient(getApplicationContext()).create(PredefinedStatusesService.class);
|
||||||
|
|
||||||
PredefinedCoordViewModel droppedMarkercoordinate = new PredefinedCoordViewModel(
|
PredefinedCoordViewModel droppedMarkercoordinate = new PredefinedCoordViewModel(
|
||||||
latLng.getLatitude(),
|
latLng.getLatitude(),
|
||||||
@ -397,7 +363,7 @@ Log.e("LOCALE",PrefUtils.getLocale(getApplicationContext()));
|
|||||||
|
|
||||||
CompositeDisposable disposable = new CompositeDisposable();
|
CompositeDisposable disposable = new CompositeDisposable();
|
||||||
disposable.add(
|
disposable.add(
|
||||||
predefinedCoordinatesService.postUserPredefinedCoord(PrefUtils.getUserId(getApplicationContext()), droppedMarkercoordinate)
|
predefinedStatusesService.postUserPredefinedCoord(PrefUtils.getUserId(getApplicationContext()), droppedMarkercoordinate)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(this::SaveCurrentManualLocation, this::handleError)
|
.subscribe(this::SaveCurrentManualLocation, this::handleError)
|
||||||
@ -409,30 +375,6 @@ Log.e("LOCALE",PrefUtils.getLocale(getApplicationContext()));
|
|||||||
PrefUtils.putCurrentManualLocation(getApplicationContext(), resp.getPredefinedCoordinateId());
|
PrefUtils.putCurrentManualLocation(getApplicationContext(), resp.getPredefinedCoordinateId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void checkIfUsesCanBeTutor(){
|
|
||||||
disposable.add(
|
|
||||||
userService.getSelf(myId)
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribeWith(new DisposableSingleObserver<User>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(User user) {
|
|
||||||
boolean tutorFromBackend = user.getTitle().equals("tutor");
|
|
||||||
|
|
||||||
if(tutorFromBackend != PrefUtils.getIsTutor(getApplicationContext())){
|
|
||||||
logout();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(Throwable e) {
|
|
||||||
showError(e);
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void fetchTopCoords() {
|
private void fetchTopCoords() {
|
||||||
|
|
||||||
disposable.add(
|
disposable.add(
|
||||||
@ -645,6 +587,47 @@ Log.e("LOCALE",PrefUtils.getLocale(getApplicationContext()));
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add the mapView lifecycle to the activity's lifecycle methods
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
mapView.onResume();
|
||||||
|
shouldFetchNewCoords = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart() {
|
||||||
|
super.onStart();
|
||||||
|
mapView.onStart();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop() {
|
||||||
|
super.onStop();
|
||||||
|
mapView.onStop();
|
||||||
|
shouldFetchNewCoords = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
mapView.onPause();
|
||||||
|
shouldFetchNewCoords = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLowMemory() {
|
||||||
|
super.onLowMemory();
|
||||||
|
mapView.onLowMemory();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
mapView.onDestroy();
|
||||||
|
mHandler.removeCallbacks(mStatusChecker);
|
||||||
|
disposable.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onSaveInstanceState(Bundle outState) {
|
protected void onSaveInstanceState(Bundle outState) {
|
||||||
@ -654,7 +637,6 @@ Log.e("LOCALE",PrefUtils.getLocale(getApplicationContext()));
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getContentViewId() {
|
protected int getContentViewId() {
|
||||||
Mapbox.getInstance(this, getString(R.string.access_token));
|
|
||||||
return R.layout.activity_map;
|
return R.layout.activity_map;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -687,13 +669,11 @@ Log.e("LOCALE",PrefUtils.getLocale(getApplicationContext()));
|
|||||||
@Override
|
@Override
|
||||||
public void searchUser(String textToSearch) {
|
public void searchUser(String textToSearch) {
|
||||||
getUserFromApi(textToSearch);
|
getUserFromApi(textToSearch);
|
||||||
|
|
||||||
Log.e("LOCALE", LocaleUtils.getCurrentLocale());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getUserFromApi(String userNameToSearch) {
|
private void getUserFromApi(String userNameToSearch) {
|
||||||
disposable.add(
|
disposable.add(
|
||||||
userService.getAllOnlineTutors()
|
userService.getAllTutors()
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.map(tutors -> Stream.of(tutors).filter(t ->
|
.map(tutors -> Stream.of(tutors).filter(t ->
|
||||||
@ -701,7 +681,6 @@ Log.e("LOCALE",PrefUtils.getLocale(getApplicationContext()));
|
|||||||
.subscribeWith(new DisposableSingleObserver<List<User>>() {
|
.subscribeWith(new DisposableSingleObserver<List<User>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(List<User> users) {
|
public void onSuccess(List<User> users) {
|
||||||
Log.e("USERS", String.valueOf(users));
|
|
||||||
filterMarkers(users);
|
filterMarkers(users);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -712,7 +691,7 @@ Log.e("LOCALE",PrefUtils.getLocale(getApplicationContext()));
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void filterMarkers(List<User> users) {
|
private void filterMarkers(List<User> users) {
|
||||||
restoreMapMarkers();
|
restoreMapMarkers();
|
||||||
|
|
||||||
Icon markedMarker = IconFactory.getInstance(MapActivity.this).fromResource(R.drawable.search_marker);
|
Icon markedMarker = IconFactory.getInstance(MapActivity.this).fromResource(R.drawable.search_marker);
|
||||||
@ -733,65 +712,18 @@ Log.e("LOCALE",PrefUtils.getLocale(getApplicationContext()));
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void restoreMapMarkers() {
|
public void restoreMapMarkers() {
|
||||||
try {
|
|
||||||
for (Marker marker : mapboxMap.getMarkers()) {
|
|
||||||
MapMarker markerMap = markerHash.get(markerUserHash.get(marker.getId()));
|
|
||||||
|
|
||||||
markerMap.restoreDefaultIcon();
|
for (Marker marker : mapboxMap.getMarkers()) {
|
||||||
mapboxMap.deselectMarker(marker);
|
MapMarker markerMap = markerHash.get(markerUserHash.get(marker.getId()));
|
||||||
}
|
|
||||||
|
|
||||||
mapboxMap.getMarkerViewManager().update();
|
markerMap.restoreDefaultIcon();
|
||||||
} catch (Exception e) {
|
mapboxMap.deselectMarker(marker);
|
||||||
Log.e("MAP", String.valueOf(e));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mapboxMap.getMarkerViewManager().update();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void adjustMapToSearch(Integer zoom) {
|
public void adjustMapToSearch(Integer zoom) {
|
||||||
MapUtils.setZoom(mapboxMap, zoom);
|
MapUtils.setZoom(mapboxMap, zoom);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
mapView.onResume();
|
|
||||||
shouldFetchNewCoords = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStart() {
|
|
||||||
super.onStart();
|
|
||||||
mapView.onStart();
|
|
||||||
shouldFetchNewCoords = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStop() {
|
|
||||||
super.onStop();
|
|
||||||
mapView.onStop();
|
|
||||||
shouldFetchNewCoords = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPause() {
|
|
||||||
super.onPause();
|
|
||||||
mapView.onPause();
|
|
||||||
shouldFetchNewCoords = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onLowMemory() {
|
|
||||||
super.onLowMemory();
|
|
||||||
mapView.onLowMemory();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onDestroy() {
|
|
||||||
super.onDestroy();
|
|
||||||
mapView.onDestroy();
|
|
||||||
mHandler.removeCallbacks(mStatusChecker);
|
|
||||||
disposable.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.uam.wmi.findmytutor.activity;
|
package com.uam.wmi.findmytutor.activity;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
@ -12,19 +11,15 @@ import android.preference.Preference;
|
|||||||
import android.preference.PreferenceFragment;
|
import android.preference.PreferenceFragment;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
||||||
import com.uam.wmi.findmytutor.R;
|
import com.uam.wmi.findmytutor.R;
|
||||||
import com.uam.wmi.findmytutor.utils.LocaleHelper;
|
|
||||||
import com.uam.wmi.findmytutor.utils.LocaleUtils;
|
|
||||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||||
|
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class SettingsActivity extends AppCompatPreferenceActivity {
|
public class SettingsActivity extends AppCompatPreferenceActivity {
|
||||||
private static final String TAG = SettingsActivity.class.getSimpleName();
|
private static final String TAG = SettingsActivity.class.getSimpleName();
|
||||||
|
|
||||||
@ -37,15 +32,9 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||||||
getFragmentManager().beginTransaction().replace(android.R.id.content, new MainPreferenceFragment()).commit();
|
getFragmentManager().beginTransaction().replace(android.R.id.content, new MainPreferenceFragment()).commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void attachBaseContext(Context base) {
|
|
||||||
super.attachBaseContext(LocaleHelper.onAttach(base));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLocale(String localeName) {
|
public void setLocale(String localeName) {
|
||||||
Context context = LocaleHelper.setLocale(this, localeName);
|
|
||||||
Resources res = context.getResources();
|
|
||||||
Locale myLocale = new Locale(localeName);
|
Locale myLocale = new Locale(localeName);
|
||||||
|
Resources res = getResources();
|
||||||
DisplayMetrics dm = res.getDisplayMetrics();
|
DisplayMetrics dm = res.getDisplayMetrics();
|
||||||
Configuration conf = res.getConfiguration();
|
Configuration conf = res.getConfiguration();
|
||||||
conf.locale = myLocale;
|
conf.locale = myLocale;
|
||||||
@ -65,19 +54,16 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||||||
Preference languagesList = findPreference(getResources().getString(R.string.key_language));
|
Preference languagesList = findPreference(getResources().getString(R.string.key_language));
|
||||||
languagesList.setDefaultValue(0);
|
languagesList.setDefaultValue(0);
|
||||||
|
|
||||||
if(PrefUtils.getLocale(getActivity()).equals("1")){
|
if(PrefUtils.getLocale(getActivity()).equals("pl")){
|
||||||
languagesList.setDefaultValue(1);
|
languagesList.setDefaultValue(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
languagesList.setOnPreferenceChangeListener((preference, newValue) -> {
|
languagesList.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||||
|
|
||||||
if (!newValue.toString().equals("0")){
|
if (!newValue.toString().equals("0")){
|
||||||
LocaleHelper.setLocale(getActivity(), "pl");
|
|
||||||
((SettingsActivity)getActivity()).setLocale("pl");
|
((SettingsActivity)getActivity()).setLocale("pl");
|
||||||
PrefUtils.storeLocale(getActivity(),"pl");
|
PrefUtils.storeLocale(getActivity(),"pl");
|
||||||
LocaleHelper.setLocale(getActivity(), "pl");
|
|
||||||
}else{
|
}else{
|
||||||
LocaleHelper.setLocale(getActivity(), "en");
|
|
||||||
((SettingsActivity)getActivity()).setLocale("en");
|
((SettingsActivity)getActivity()).setLocale("en");
|
||||||
PrefUtils.storeLocale(getActivity(),"en");
|
PrefUtils.storeLocale(getActivity(),"en");
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,12 @@
|
|||||||
package com.uam.wmi.findmytutor.activity;
|
package com.uam.wmi.findmytutor.activity;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.app.FragmentTransaction;
|
import android.app.FragmentTransaction;
|
||||||
import android.content.Context;
|
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.ListPreference;
|
import android.preference.ListPreference;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.PreferenceCategory;
|
import android.preference.PreferenceCategory;
|
||||||
import android.preference.PreferenceFragment;
|
import android.preference.PreferenceFragment;
|
||||||
import android.preference.SwitchPreference;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -24,17 +19,13 @@ import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
|
|||||||
import com.uam.wmi.findmytutor.R;
|
import com.uam.wmi.findmytutor.R;
|
||||||
import com.uam.wmi.findmytutor.model.PredefinedCoordViewModel;
|
import com.uam.wmi.findmytutor.model.PredefinedCoordViewModel;
|
||||||
import com.uam.wmi.findmytutor.network.ApiClient;
|
import com.uam.wmi.findmytutor.network.ApiClient;
|
||||||
import com.uam.wmi.findmytutor.service.PredefinedCoordinatesService;
|
|
||||||
import com.uam.wmi.findmytutor.service.PredefinedStatusesService;
|
import com.uam.wmi.findmytutor.service.PredefinedStatusesService;
|
||||||
import com.uam.wmi.findmytutor.utils.EnableSharingDialog;
|
|
||||||
import com.uam.wmi.findmytutor.utils.LocaleHelper;
|
|
||||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||||
import com.uam.wmi.findmytutor.utils.RestApiHelper;
|
import com.uam.wmi.findmytutor.utils.RestApiHelper;
|
||||||
import com.uam.wmi.findmytutor.utils.RightButtonPreference;
|
import com.uam.wmi.findmytutor.utils.RightButtonPreference;
|
||||||
import com.uam.wmi.findmytutor.utils.SharingLevel;
|
import com.uam.wmi.findmytutor.utils.SharingLevel;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@ -48,29 +39,19 @@ import okhttp3.ResponseBody;
|
|||||||
import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext;
|
import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext;
|
||||||
|
|
||||||
|
|
||||||
public class SharingFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
|
public class SharingFragment extends PreferenceFragment {
|
||||||
protected SwitchPreference locationSharing;
|
protected Preference locationSharing;
|
||||||
protected SwitchPreference statusSwitch;
|
|
||||||
protected Preference locationMode;
|
protected Preference locationMode;
|
||||||
protected ListPreference manualLocationList;
|
protected Preference manualLocationList;
|
||||||
protected PreferenceCategory preferenceCategory;
|
protected PreferenceCategory preferenceCategory;
|
||||||
protected RightButtonPreference manualLocationButton;
|
protected RightButtonPreference manualLocationButton;
|
||||||
protected RightButtonPreference removeManualLocation;
|
|
||||||
protected RightButtonPreference removeManualStatus;
|
|
||||||
protected Preference manualStatus;
|
protected Preference manualStatus;
|
||||||
protected ListPreference statusList;
|
protected ListPreference statusList;
|
||||||
protected List<PredefinedCoordViewModel> predefinedCoordsList = new ArrayList<>();
|
protected List<PredefinedCoordViewModel> predefinedCoordsList = new ArrayList<>();
|
||||||
private HashMap<String, String> locationMap;
|
|
||||||
private ArrayList<String> locationUUIDs;
|
|
||||||
private HashMap<Integer, String> locationLevelMapping;
|
private HashMap<Integer, String> locationLevelMapping;
|
||||||
private HashMap<Integer, String> statusMapping;
|
private HashMap<Integer, String> statusMapping;
|
||||||
private PredefinedStatusesService statusesService;
|
private PredefinedStatusesService statusesService;
|
||||||
private PredefinedCoordinatesService locationService;
|
|
||||||
private CompositeDisposable disposable;
|
private CompositeDisposable disposable;
|
||||||
private AlertDialog.Builder builder;
|
|
||||||
private String[] statusesArray;
|
|
||||||
private boolean statusSwitchFlag;
|
|
||||||
private ArrayList<String> predefinedLocationsList;
|
|
||||||
|
|
||||||
public static SharingFragment newInstance() {
|
public static SharingFragment newInstance() {
|
||||||
return new SharingFragment();
|
return new SharingFragment();
|
||||||
@ -84,14 +65,8 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
|||||||
.subscribeWith(new DisposableSingleObserver<List<String>>() {
|
.subscribeWith(new DisposableSingleObserver<List<String>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(List<String> strings) {
|
public void onSuccess(List<String> strings) {
|
||||||
statusesArray = strings.toArray(new String[strings.size()]);
|
String[] statusesArray = strings.toArray(new String[strings.size()]);
|
||||||
if (strings.isEmpty()) {
|
setListPreferenceData(statusList.getKey(), statusesArray,strings.size() -1);
|
||||||
disableStatusPreferences();
|
|
||||||
} else {
|
|
||||||
enableStatusPreferences();
|
|
||||||
}
|
|
||||||
// Log.d("STATUSES",Integer.toString(statusesArray.length ));
|
|
||||||
setListPreferenceData(statusList, statusesArray, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -103,81 +78,57 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
|||||||
}
|
}
|
||||||
|
|
||||||
void getLocations(CompositeDisposable disposable) {
|
void getLocations(CompositeDisposable disposable) {
|
||||||
disposable.add(locationService.getUserPredefinedCoords(PrefUtils.getUserId(getApplicationContext()))
|
disposable.add(statusesService.getUserPredefinedCoords(PrefUtils.getUserId(getApplicationContext()))
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribeWith(new DisposableSingleObserver<List<PredefinedCoordViewModel>>() {
|
.subscribeWith(new DisposableSingleObserver<List<PredefinedCoordViewModel>>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(List<PredefinedCoordViewModel> coords) {
|
public void onSuccess(List<PredefinedCoordViewModel> coords) {
|
||||||
|
List<String> names = Stream.of(coords).map(PredefinedCoordViewModel::getName).collect(com.annimon.stream.Collectors.toList());
|
||||||
String currentCoordId = PrefUtils.getCurrentManualLocation(getApplicationContext());
|
|
||||||
locationMap = new HashMap<String, String>();
|
|
||||||
locationUUIDs = new ArrayList<String>();
|
|
||||||
for (PredefinedCoordViewModel i : coords)
|
|
||||||
locationMap.put(i.getPredefinedCoordinateId(), i.getName());
|
|
||||||
for (PredefinedCoordViewModel i : coords)
|
|
||||||
locationUUIDs.add(i.getPredefinedCoordinateId());
|
|
||||||
List<String> predefinedLocationsNames = Stream.of(coords).map(PredefinedCoordViewModel::getName).toList();
|
|
||||||
List<String> predefinedLocationsUUIDs = Stream.of(coords).map(PredefinedCoordViewModel::getPredefinedCoordinateId).toList();
|
|
||||||
predefinedCoordsList.addAll(coords);
|
predefinedCoordsList.addAll(coords);
|
||||||
if (!PrefUtils.getLocationLevel(getApplicationContext()).equals("manual")) {
|
String[] stringnames = names.toArray(new String[0]);
|
||||||
preferenceCategory.removePreference(manualLocationList);
|
String currentCoordId = PrefUtils.getCurrentManualLocation(getApplicationContext());
|
||||||
preferenceCategory.removePreference(removeManualLocation);
|
|
||||||
preferenceCategory.removePreference(manualLocationButton);
|
|
||||||
} else {
|
|
||||||
if (!predefinedCoordsList.isEmpty()) {
|
|
||||||
|
|
||||||
manualLocationList.setEnabled(true);
|
List<Integer> activeId = Stream.of(coords).indexed()
|
||||||
manualLocationList.setSummary(PrefUtils.getCurrentManualLocationName(getApplicationContext()));
|
|
||||||
removeManualLocation.setEnabled(true);
|
|
||||||
locationSharing.setEnabled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
String[] stringnames = predefinedLocationsNames.toArray(new String[0]);
|
|
||||||
predefinedLocationsList = new ArrayList<>(Arrays.asList(stringnames));
|
|
||||||
List<Integer> activesId = Stream.of(coords).indexed()
|
|
||||||
.filter(v -> v.getSecond().getPredefinedCoordinateId().equals(currentCoordId)).map(IntPair::getFirst).toList();
|
.filter(v -> v.getSecond().getPredefinedCoordinateId().equals(currentCoordId)).map(IntPair::getFirst).toList();
|
||||||
|
|
||||||
if (activesId.size() == 0) {
|
if(activeId.size() > 0)
|
||||||
setListPreferenceData(manualLocationList, stringnames, null);
|
setListPreferenceData(manualLocationList.getKey(), stringnames, activeId.get(0));
|
||||||
} else {
|
else{
|
||||||
setListPreferenceData(manualLocationList, stringnames, activesId.get(0));
|
setListPreferenceData(manualLocationList.getKey(), stringnames,null);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(Throwable e) {
|
public void onError(Throwable e) {
|
||||||
Toast.makeText(getApplicationContext(), R.string.error_location_fetch, Toast.LENGTH_SHORT).show();
|
Toast.makeText(getApplicationContext(), R.string.manual_status_error, Toast.LENGTH_SHORT).show();
|
||||||
|
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@SuppressLint("ResourceType")
|
@SuppressLint("ResourceType")
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(final Bundle savedInstanceState) {
|
public void onCreate(final Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
addPreferencesFromResource(R.xml.pref_sharing);
|
addPreferencesFromResource(R.layout.pref_sharing);
|
||||||
locationSharing = (SwitchPreference) findPreference("key_sharing_enabled");
|
locationSharing = findPreference("key_sharing_enabled");
|
||||||
statusSwitch = (SwitchPreference) findPreference("key_status_enabled");
|
|
||||||
locationMode = findPreference("key_location_level");
|
locationMode = findPreference("key_location_level");
|
||||||
preferenceCategory = (PreferenceCategory) findPreference("category_sharing");
|
preferenceCategory = (PreferenceCategory) findPreference("category_sharing");
|
||||||
manualLocationList = (ListPreference) findPreference("key_manual_location_value");
|
manualLocationList = findPreference("key_manual_location_value");
|
||||||
manualLocationButton = (RightButtonPreference) findPreference("manual_location_button");
|
manualLocationButton = (RightButtonPreference) findPreference("manual_location_button");
|
||||||
removeManualLocation = (RightButtonPreference) findPreference("remove_manual_location");
|
|
||||||
builder = new AlertDialog.Builder(getActivity());
|
|
||||||
removeManualStatus = (RightButtonPreference) findPreference("remove_manual_status");
|
|
||||||
manualStatus = findPreference("key_manual_status");
|
manualStatus = findPreference("key_manual_status");
|
||||||
statusList = (ListPreference) findPreference("key_status_value");
|
statusList = (ListPreference) findPreference("key_status_value");
|
||||||
|
|
||||||
statusesService = ApiClient.getClient(getApplicationContext()).create(PredefinedStatusesService.class);
|
statusesService = ApiClient.getClient(getApplicationContext()).create(PredefinedStatusesService.class);
|
||||||
locationService = ApiClient.getClient(getApplicationContext()).create(PredefinedCoordinatesService.class);
|
|
||||||
disposable = new CompositeDisposable();
|
disposable = new CompositeDisposable();
|
||||||
statusesArray = new String[0];
|
|
||||||
predefinedLocationsList = new ArrayList<String>();
|
|
||||||
getStatuses(disposable);
|
getStatuses(disposable);
|
||||||
getLocations(disposable);
|
|
||||||
|
if (PrefUtils.getLocationLevel(getApplicationContext()).equals("manual")) {
|
||||||
|
getLocations(disposable);
|
||||||
|
}
|
||||||
|
|
||||||
locationLevelMapping = new HashMap<Integer, String>();
|
locationLevelMapping = new HashMap<Integer, String>();
|
||||||
locationLevelMapping.put(0, SharingLevel.PRESENCE.toString());
|
locationLevelMapping.put(0, SharingLevel.PRESENCE.toString());
|
||||||
locationLevelMapping.put(1, SharingLevel.APPROXIMATED.toString());
|
locationLevelMapping.put(1, SharingLevel.APPROXIMATED.toString());
|
||||||
@ -189,10 +140,6 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
|||||||
statusMapping.put(1, "consultation");
|
statusMapping.put(1, "consultation");
|
||||||
statusMapping.put(2, "busy");
|
statusMapping.put(2, "busy");
|
||||||
|
|
||||||
statusList.setSummary(PrefUtils.getUserStatus(getApplicationContext()));
|
|
||||||
manualLocationList.setSummary(PrefUtils.getCurrentManualLocationName(getApplicationContext()));
|
|
||||||
|
|
||||||
|
|
||||||
/** Main sharing switch**/
|
/** Main sharing switch**/
|
||||||
locationSharing.setOnPreferenceChangeListener((buttonView, newValue) -> {
|
locationSharing.setOnPreferenceChangeListener((buttonView, newValue) -> {
|
||||||
PrefUtils.storeEnableSharingLocalization(getApplicationContext(), (Boolean) newValue);
|
PrefUtils.storeEnableSharingLocalization(getApplicationContext(), (Boolean) newValue);
|
||||||
@ -202,45 +149,35 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
|||||||
|
|
||||||
/** Sharing level list **/
|
/** Sharing level list **/
|
||||||
locationMode.setOnPreferenceChangeListener((preference, newValue) -> {
|
locationMode.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||||
((MapActivity) getActivity()).stopBackgroundLocalizationTask();
|
|
||||||
((MapActivity) getActivity()).startBackgroundLocalizationTask();
|
|
||||||
PrefUtils.storeLocationMode(getApplicationContext(), locationLevelMapping.get(Integer.parseInt((String) newValue)));
|
|
||||||
|
|
||||||
if (PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.MANUAL.toString())) {
|
PrefUtils.storeLocationMode(getApplicationContext(), locationLevelMapping.get(Integer.parseInt((String) newValue)));
|
||||||
if (!predefinedCoordsList.isEmpty()) {
|
if (PrefUtils.getLocationLevel(getApplicationContext()).equals("manual")) {
|
||||||
preferenceCategory.addPreference(manualLocationList);
|
|
||||||
preferenceCategory.addPreference(removeManualLocation);
|
preferenceCategory.addPreference(manualLocationList);
|
||||||
}
|
getLocations(disposable);
|
||||||
preferenceCategory.addPreference(manualLocationButton);
|
preferenceCategory.addPreference(manualLocationButton);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
locationSharing.setEnabled(true);
|
|
||||||
preferenceCategory.removePreference(manualLocationList);
|
preferenceCategory.removePreference(manualLocationList);
|
||||||
preferenceCategory.removePreference(manualLocationButton);
|
preferenceCategory.removePreference(manualLocationButton);
|
||||||
preferenceCategory.removePreference(removeManualLocation);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
/** Manual location category hiding when location level is != manual **/
|
/** Manual location category hiding when location level is != manual **/
|
||||||
|
if (!PrefUtils.getLocationLevel(getApplicationContext()).equals("manual")) {
|
||||||
|
preferenceCategory.removePreference(manualLocationList);
|
||||||
|
preferenceCategory.removePreference(manualLocationButton);
|
||||||
|
}
|
||||||
|
|
||||||
/** Custom manual location list change listener **/
|
/** Custom manual location list change listener **/
|
||||||
manualLocationList.setOnPreferenceChangeListener((preference, newValue) -> {
|
manualLocationList.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||||
ListPreference lp = (ListPreference) preference;
|
ListPreference lp = (ListPreference) preference;
|
||||||
CharSequence[] entries = lp.getEntries();
|
|
||||||
PredefinedCoordViewModel temp = Stream.of(predefinedCoordsList).filter(p -> p.getName().equals(lp.getEntries()[Integer.parseInt((String) newValue)].toString())).toList().get(0);
|
PredefinedCoordViewModel temp = Stream.of(predefinedCoordsList).filter(p -> p.getName().equals(lp.getEntries()[Integer.parseInt((String) newValue)].toString())).toList().get(0);
|
||||||
|
|
||||||
//sharing dialog -> ask for start BG
|
PrefUtils.putManualLocation(getApplicationContext(), temp.getGeoData(), temp.getApproximatedLocation() );
|
||||||
if (!PrefUtils.isEnableSharingLocalization(getApplicationContext())) {
|
PrefUtils.putCurrentManualLocation(getApplicationContext(),temp.getPredefinedCoordinateId());
|
||||||
EnableSharingDialog sharingDialog = new EnableSharingDialog();
|
|
||||||
sharingDialog.show(getFragmentManager(), "Sharing");
|
|
||||||
}
|
|
||||||
|
|
||||||
PrefUtils.putManualLocation(getApplicationContext(), temp.getGeoData(), temp.getApproximatedLocation());
|
|
||||||
PrefUtils.putCurrentManualLocation(getApplicationContext(), temp.getPredefinedCoordinateId());
|
|
||||||
PrefUtils.putCurrentManualLocationName(getApplicationContext(), (String) lp.getEntries()[Integer.parseInt((String) newValue)]);
|
|
||||||
lp.setSummary(lp.getEntries()[Integer.parseInt((String) newValue)]);
|
|
||||||
((MapActivity) getActivity()).handleBackgroundTaskLifeCycle();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
@ -250,29 +187,18 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
|||||||
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
|
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
|
||||||
fragmentTransaction.hide(SharingFragment.this);
|
fragmentTransaction.hide(SharingFragment.this);
|
||||||
fragmentTransaction.commit();
|
fragmentTransaction.commit();
|
||||||
((MapActivity) getActivity()).updateNavigationBarState();
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
statusSwitch.setOnPreferenceChangeListener((preference, newValue) -> true);
|
|
||||||
/** Status list change listener **/
|
/** Status list change listener **/
|
||||||
statusList.setOnPreferenceChangeListener((preference, newValue) -> {
|
statusList.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||||
ListPreference lp = (ListPreference) preference;
|
ListPreference lp = (ListPreference) preference;
|
||||||
CharSequence[] entries = lp.getEntries();
|
CharSequence[] entries = lp.getEntries();
|
||||||
PrefUtils.storeStatus(getApplicationContext(), (String) entries[Integer.parseInt((String) newValue)]);
|
PrefUtils.storeStatus(getApplicationContext(), (String) entries[Integer.parseInt((String) newValue)]);
|
||||||
lp.setSummary(entries[Integer.parseInt((String) newValue)]);
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
statusList.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
/** Custom status list change listener **/
|
||||||
@Override
|
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
|
||||||
|
|
||||||
if (statusesArray.length == 0) {
|
|
||||||
builder.setTitle("nie ma wody na pustyni");
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
/** Custom status edittext change listener **/
|
|
||||||
manualStatus.setOnPreferenceChangeListener((preference, newValue) -> {
|
manualStatus.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||||
|
|
||||||
disposable.add(statusesService.postUserPredefinedStatus(PrefUtils.getUserId(getApplicationContext()), (String) newValue)
|
disposable.add(statusesService.postUserPredefinedStatus(PrefUtils.getUserId(getApplicationContext()), (String) newValue)
|
||||||
@ -280,43 +206,10 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
|||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(this::handleResponse, this::handleError));
|
.subscribe(this::handleResponse, this::handleError));
|
||||||
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
removeManualStatus.setOnPreferenceChangeListener((preference, newValue) -> {
|
|
||||||
showRemoveDialog(statusList.getEntries(), "status");
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
removeManualLocation.setOnPreferenceChangeListener(((preference, newValue) -> {
|
|
||||||
showRemoveDialog(manualLocationList.getEntries(), "location");
|
|
||||||
return true;
|
|
||||||
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void showRemoveDialog(CharSequence[] entries, String service) {
|
|
||||||
boolean[] checked = new boolean[entries.length];
|
|
||||||
ArrayList<String> tobeDeleted = new ArrayList<String>();
|
|
||||||
// Log.d("sharingDialog", "no to siup");
|
|
||||||
builder.setPositiveButton("DELETE", new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
for (int i = 0; i < entries.length; i++) {
|
|
||||||
if (checked[i] == true) {
|
|
||||||
tobeDeleted.add((String) entries[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
removeEntries(service, tobeDeleted);
|
|
||||||
// Log.d("MANAGE-PREF",tobeDeleted.toString());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
builder.setMultiChoiceItems(entries, checked, new DialogInterface.OnMultiChoiceClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
builder.create().show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -327,73 +220,30 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
|||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void removeEntries(String service, ArrayList<String> toBeDeleted) {
|
protected void setListPreferenceData(String lp_name, String[] entries, Integer activeId) {
|
||||||
|
ListPreference lp = (ListPreference) findPreference(lp_name);
|
||||||
|
lp.setEntries(entries);
|
||||||
|
CharSequence[] entryValues = new CharSequence[entries.length];
|
||||||
|
|
||||||
// Log.d("MANAGE-PREF", toBeDeleted.toString());
|
for (int i = 0; i < entries.length; i++) {
|
||||||
if (service.equals("status")) {
|
entryValues[i] = Integer.toString(i);
|
||||||
for (String uuid : toBeDeleted) {
|
|
||||||
disposable.add(statusesService.deleteUserPredefinedStatus(PrefUtils.getUserId(getApplicationContext()), uuid)
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribe(this::handleDeleteStatuses, this::handleError));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ArrayList<String> uuidsToBeDeleted = new ArrayList<String>();
|
|
||||||
for (String name : toBeDeleted) {
|
|
||||||
for (String uuid : locationUUIDs) {
|
|
||||||
if (locationMap.get(uuid).equals(name)) {
|
|
||||||
uuidsToBeDeleted.add(uuid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (String uuid : uuidsToBeDeleted) {
|
|
||||||
// predefinedCoordsList.removeIf(x -> x.getPredefinedCoordinateId().equals(uuid));
|
|
||||||
predefinedCoordsList.removeAll(Stream.of(predefinedCoordsList).filter(x -> x.getPredefinedCoordinateId().equals(uuid)).toList());
|
|
||||||
disposable.add(locationService.deleteUserPredefinedCoord(PrefUtils.getUserId(getApplicationContext()), uuid)
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribe(this::handleDeleteLocations, this::handleError));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void setListPreferenceData(ListPreference lp, String[] entries, Integer activeId) {
|
|
||||||
|
|
||||||
try {
|
|
||||||
lp.setEntries(entries);
|
|
||||||
CharSequence[] entryValues = new CharSequence[entries.length];
|
|
||||||
|
|
||||||
for (int i = 0; i < entries.length; i++) {
|
|
||||||
entryValues[i] = Integer.toString(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
lp.setDefaultValue(0);
|
|
||||||
lp.setEntryValues(entryValues);
|
|
||||||
|
|
||||||
if (entries.length > 0 && activeId != null)
|
|
||||||
lp.setValueIndex(activeId);
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.e("Failed to set listPref", e.getMessage());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
lp.setDefaultValue(0);
|
||||||
|
lp.setEntryValues(entryValues);
|
||||||
|
|
||||||
;
|
if(entries.length > 0 && activeId != null)
|
||||||
|
lp.setValueIndex(activeId);
|
||||||
|
};
|
||||||
|
|
||||||
private void handleResponse(List<String> resp) {
|
private void handleResponse(List<String> resp) {
|
||||||
if (resp.size() == 1) {
|
|
||||||
enableStatusPreferences();
|
|
||||||
if (PrefUtils.isStatusEnabled(getApplicationContext()) == false) {
|
|
||||||
PrefUtils.enableStatus(getApplicationContext());
|
|
||||||
statusSwitch.setChecked(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
String[] statusesArray = resp.toArray(new String[resp.size()]);
|
String[] statusesArray = resp.toArray(new String[resp.size()]);
|
||||||
setListPreferenceData(statusList, statusesArray, resp.size() - 1);
|
|
||||||
|
setListPreferenceData(statusList.getKey(), statusesArray,resp.size() - 1);
|
||||||
|
|
||||||
statusList.setValueIndex(resp.size() - 1);
|
statusList.setValueIndex(resp.size() - 1);
|
||||||
PrefUtils.storeStatus(getApplicationContext(), resp.get(resp.size() - 1));
|
PrefUtils.storeStatus(getApplicationContext(), resp.get(resp.size() - 1));
|
||||||
statusList.setSummary(PrefUtils.getUserStatus(getApplicationContext()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleError(Throwable error) {
|
private void handleError(Throwable error) {
|
||||||
@ -408,101 +258,4 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleDeleteStatuses(List<String> resp) {
|
|
||||||
if (resp.isEmpty()) {
|
|
||||||
disableStatusPreferences();
|
|
||||||
} else {
|
|
||||||
String[] statusesArray = resp.toArray(new String[resp.size()]);
|
|
||||||
setListPreferenceData(statusList, statusesArray, null);
|
|
||||||
String currentEntry = PrefUtils.getUserStatus(getApplicationContext());
|
|
||||||
if (resp.contains(currentEntry)) {
|
|
||||||
statusList.setValueIndex(resp.indexOf(currentEntry));
|
|
||||||
} else {
|
|
||||||
statusList.setValueIndex(0);
|
|
||||||
statusList.setSummary(resp.get(0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleDeleteLocations(List<PredefinedCoordViewModel> resp) {
|
|
||||||
getLocations(disposable);
|
|
||||||
String currentEntry = PrefUtils.getCurrentManualLocation(getApplicationContext());
|
|
||||||
if (resp.isEmpty()) {
|
|
||||||
disableManualLocationPreferences();
|
|
||||||
} else {
|
|
||||||
if (!Stream.of(resp).filter(x -> x.getName().equals(currentEntry)).toList().isEmpty()) {
|
|
||||||
for (PredefinedCoordViewModel location : resp) {
|
|
||||||
if (location.getName().equals(currentEntry)) {
|
|
||||||
manualLocationList.setValueIndex(resp.indexOf(location));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
manualLocationList.setValueIndex(0);
|
|
||||||
manualLocationList.setSummary(resp.get(0).getName());
|
|
||||||
//todo czy na pewno w shared pref sa dobre wartosci
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void disableStatusPreferences() {
|
|
||||||
removeManualStatus.setEnabled(false);
|
|
||||||
statusList.setEnabled(false);
|
|
||||||
statusSwitch.setEnabled(false);
|
|
||||||
statusList.setSummary("");
|
|
||||||
PrefUtils.disableStatus(getApplicationContext());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void enableStatusPreferences() {
|
|
||||||
removeManualStatus.setEnabled(true);
|
|
||||||
statusList.setEnabled(true);
|
|
||||||
statusSwitch.setEnabled(true);
|
|
||||||
statusList.setSummary(PrefUtils.getUserStatus(getApplicationContext()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void disableManualLocationPreferences() {
|
|
||||||
removeManualLocation.setEnabled(false);
|
|
||||||
manualLocationList.setEnabled(false);
|
|
||||||
manualLocationList.setSummary("");
|
|
||||||
locationSharing.setChecked(false);
|
|
||||||
locationSharing.setEnabled(false);
|
|
||||||
PrefUtils.disableSharing(getApplicationContext());
|
|
||||||
((MapActivity) getActivity()).handleBackgroundTaskLifeCycle();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void enableManualLocationPreferences() {
|
|
||||||
removeManualLocation.setEnabled(true);
|
|
||||||
manualLocationList.setEnabled(true);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
|
||||||
locationSharing.setChecked(PrefUtils.isEnableSharingLocalization(getApplicationContext()));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPause() {
|
|
||||||
getPreferenceManager().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
|
|
||||||
super.onPause();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDestroy() {
|
|
||||||
super.onDestroy();
|
|
||||||
disposable.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
package com.uam.wmi.findmytutor.activity;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.v7.app.AppCompatActivity;
|
|
||||||
|
|
||||||
import com.uam.wmi.findmytutor.R;
|
|
||||||
|
|
||||||
public abstract class SpecialList extends AppCompatActivity {
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState){
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setContentView(getContentViewId());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract int getContentViewId();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,29 +1,15 @@
|
|||||||
package com.uam.wmi.findmytutor.activity;
|
package com.uam.wmi.findmytutor.activity;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.app.Dialog;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.PowerManager;
|
|
||||||
import android.provider.Settings;
|
|
||||||
import android.support.v4.app.DialogFragment;
|
|
||||||
import android.support.v4.app.FragmentManager;
|
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.widget.ScrollView;
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
|
||||||
import com.uam.wmi.findmytutor.R;
|
|
||||||
import com.uam.wmi.findmytutor.utils.LocaleHelper;
|
|
||||||
import com.uam.wmi.findmytutor.utils.MapUtils;
|
|
||||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@ -32,17 +18,11 @@ public class StartupActivity extends AppCompatActivity {
|
|||||||
private static final int AUTHENTICATION_REQUEST_CODE = 666;
|
private static final int AUTHENTICATION_REQUEST_CODE = 666;
|
||||||
String currentLang;
|
String currentLang;
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void attachBaseContext(Context base) {
|
|
||||||
super.attachBaseContext(LocaleHelper.onAttach(base));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
if (PrefUtils.isLoggedIn(getApplicationContext())){
|
if (PrefUtils.isLoggedIn(getApplicationContext())){
|
||||||
Intent startupIntent = new Intent(this, MapActivity.class);
|
Intent startupIntent = new Intent(this, MapActivity.class);
|
||||||
PrefUtils.storeLocale(getApplicationContext(),PrefUtils.getLocale(getApplicationContext()));
|
|
||||||
startupIntent.putExtra(currentLang, PrefUtils.getLocale(getApplicationContext()));
|
startupIntent.putExtra(currentLang, PrefUtils.getLocale(getApplicationContext()));
|
||||||
startupIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
startupIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
startActivity(startupIntent);
|
startActivity(startupIntent);
|
||||||
@ -50,10 +30,10 @@ public class StartupActivity extends AppCompatActivity {
|
|||||||
} else {
|
} else {
|
||||||
Intent loginIntent = new Intent(this, LoginActivity.class);
|
Intent loginIntent = new Intent(this, LoginActivity.class);
|
||||||
startActivityForResult(loginIntent, AUTHENTICATION_REQUEST_CODE);
|
startActivityForResult(loginIntent, AUTHENTICATION_REQUEST_CODE);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -66,8 +46,4 @@ public class StartupActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,49 +0,0 @@
|
|||||||
package com.uam.wmi.findmytutor.activity;
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.app.Dialog;
|
|
||||||
import android.app.DialogFragment;
|
|
||||||
import android.app.TimePickerDialog;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.text.format.DateFormat;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.TimePicker;
|
|
||||||
|
|
||||||
import com.uam.wmi.findmytutor.model.DutyHourViewModel;
|
|
||||||
|
|
||||||
import java.util.Calendar;
|
|
||||||
|
|
||||||
@SuppressLint("ValidFragment")
|
|
||||||
public class TimePickerFragment extends DialogFragment
|
|
||||||
implements TimePickerDialog.OnTimeSetListener {
|
|
||||||
private TextView textView;
|
|
||||||
private String field;
|
|
||||||
private DutyHourViewModel duty;
|
|
||||||
@SuppressLint("ValidFragment")
|
|
||||||
public TimePickerFragment(TextView view, DutyHourViewModel duty, String field){
|
|
||||||
this.textView = view;
|
|
||||||
this.duty=duty;
|
|
||||||
this.field=field;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
|
||||||
// Use the current time as the default values for the picker
|
|
||||||
final Calendar c = Calendar.getInstance();
|
|
||||||
int hour = c.get(Calendar.HOUR_OF_DAY);
|
|
||||||
int minute = c.get(Calendar.MINUTE);
|
|
||||||
|
|
||||||
// Create a new instance of TimePickerDialog and return it
|
|
||||||
return new TimePickerDialog(getActivity(), this, hour, minute,
|
|
||||||
DateFormat.is24HourFormat(getActivity()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
|
|
||||||
String time = String.format("%d:%02d",hourOfDay,minute);
|
|
||||||
textView.setText(time);
|
|
||||||
if(field.equals("start")){
|
|
||||||
duty.setStart(time);
|
|
||||||
}else{
|
|
||||||
duty.setEnd(time);
|
|
||||||
}
|
|
||||||
// Do something with the time chosen by the user
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,50 +1,35 @@
|
|||||||
package com.uam.wmi.findmytutor.activity;
|
package com.uam.wmi.findmytutor.activity;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.drawable.ColorDrawable;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.design.widget.TextInputEditText;
|
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
|
||||||
import android.support.v7.widget.RecyclerView;
|
|
||||||
import android.support.v7.widget.Toolbar;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Gravity;
|
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.EditText;
|
||||||
import android.widget.PopupWindow;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.annimon.stream.Stream;
|
||||||
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
|
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
|
||||||
import com.uam.wmi.findmytutor.R;
|
import com.uam.wmi.findmytutor.R;
|
||||||
import com.uam.wmi.findmytutor.adapters.DutyHoursAdapter;
|
|
||||||
import com.uam.wmi.findmytutor.model.DutyHourViewModel;
|
import com.uam.wmi.findmytutor.model.DutyHourViewModel;
|
||||||
import com.uam.wmi.findmytutor.model.TutorTabViewModel;
|
import com.uam.wmi.findmytutor.model.TutorTabViewModel;
|
||||||
import com.uam.wmi.findmytutor.model.User;
|
import com.uam.wmi.findmytutor.model.User;
|
||||||
import com.uam.wmi.findmytutor.network.ApiClient;
|
import com.uam.wmi.findmytutor.network.ApiClient;
|
||||||
import com.uam.wmi.findmytutor.service.TutorTabApi;
|
import com.uam.wmi.findmytutor.service.TutorTabApi;
|
||||||
import com.uam.wmi.findmytutor.service.UserService;
|
import com.uam.wmi.findmytutor.service.UserService;
|
||||||
import com.uam.wmi.findmytutor.utils.LocaleHelper;
|
|
||||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||||
import com.uam.wmi.findmytutor.utils.RestApiHelper;
|
import com.uam.wmi.findmytutor.utils.RestApiHelper;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
import io.reactivex.observers.DisposableSingleObserver;
|
import io.reactivex.observers.DisposableSingleObserver;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
import io.reactivex.schedulers.Schedulers;
|
||||||
import okhttp3.ResponseBody;
|
import okhttp3.ResponseBody;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
import static java.lang.String.valueOf;
|
|
||||||
|
|
||||||
public class TutorTab extends AppCompatActivity {
|
public class TutorTab extends AppCompatActivity {
|
||||||
private TutorTabApi tutorTabService;
|
private TutorTabApi tutorTabService;
|
||||||
@ -52,54 +37,59 @@ public class TutorTab extends AppCompatActivity {
|
|||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
private TextView userName;
|
private TextView userName;
|
||||||
private TextView userDutyHours;
|
private TextView userDutyHours;
|
||||||
private TextInputEditText userNote;
|
private EditText userNote;
|
||||||
private TextView userRoom;
|
private TextView userRoom;
|
||||||
private TextView userEmail;
|
private TextView userEmail;
|
||||||
private TextView department;
|
private TextView department;
|
||||||
private Button addDutyButton;
|
|
||||||
private Button saveButon;
|
private Button saveButon;
|
||||||
private Button scrapButton;
|
|
||||||
private Boolean ifTutorTabExists = true;
|
|
||||||
private List<DutyHourViewModel> dutyHourList;
|
|
||||||
private RecyclerView dutyHoursRecycller;
|
|
||||||
private DutyHoursAdapter dutyHoursAdapter;
|
|
||||||
private RecyclerView.LayoutManager dutyHoursLayoutManager;
|
|
||||||
private TutorTabViewModel newTab;
|
private TutorTabViewModel newTab;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
|
||||||
setContentView(R.layout.content_tutor_tab);
|
|
||||||
ButterKnife.bind(this);
|
|
||||||
|
|
||||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
|
||||||
toolbar.setTitle(R.string.profile_activity_title);
|
|
||||||
setSupportActionBar(toolbar);
|
|
||||||
|
|
||||||
userName = findViewById(R.id.userName);
|
|
||||||
userNote = findViewById(R.id.userNote);
|
|
||||||
userRoom = findViewById(R.id.userRoom);
|
|
||||||
userEmail = findViewById(R.id.userEmail);
|
|
||||||
department = findViewById(R.id.userDepartment);
|
|
||||||
saveButon = findViewById(R.id.saveButton);
|
|
||||||
scrapButton = findViewById(R.id.scrapTutorTab);
|
|
||||||
addDutyButton = findViewById(R.id.addDuty);
|
|
||||||
dutyHoursRecycller = findViewById(R.id.dutyHourView);
|
|
||||||
dutyHoursLayoutManager = new LinearLayoutManager(this);
|
|
||||||
dutyHoursRecycller.setLayoutManager(dutyHoursLayoutManager);
|
|
||||||
|
|
||||||
tutorTabService = ApiClient.getClient(getApplicationContext())
|
tutorTabService = ApiClient.getClient(getApplicationContext())
|
||||||
.create(TutorTabApi.class);
|
.create(TutorTabApi.class);
|
||||||
userService = ApiClient.getClient(getApplicationContext())
|
userService = ApiClient.getClient(getApplicationContext())
|
||||||
.create(UserService.class);
|
.create(UserService.class);
|
||||||
|
setContentView(R.layout.content_tutor_tab);
|
||||||
getTutorTab();
|
TextView userName = findViewById(R.id.userName);
|
||||||
|
TextView userDutyHours = findViewById(R.id.userDutyHours);
|
||||||
|
EditText userNote = findViewById(R.id.userNote);
|
||||||
|
TextView userRoom = findViewById(R.id.userRoom);
|
||||||
|
TextView userEmail = findViewById(R.id.userEmail);
|
||||||
|
TextView department = findViewById(R.id.userDepartment);
|
||||||
|
Button saveButon = findViewById(R.id.saveButon);
|
||||||
|
|
||||||
userName.setText(String.format("%s %s", PrefUtils.getUserFirstName(getApplicationContext()), PrefUtils.getUserLastName(getApplicationContext())));
|
userName.setText(String.format("%s %s", PrefUtils.getUserFirstName(getApplicationContext()), PrefUtils.getUserLastName(getApplicationContext())));
|
||||||
|
|
||||||
disposable.add(
|
disposable.add(
|
||||||
userService.getUserById(PrefUtils.getUserId(getApplicationContext()))
|
tutorTabService.apiUsersTutorTabByTutorIdGet(PrefUtils.getUserId(getApplicationContext()))
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribeWith(new DisposableSingleObserver<TutorTabViewModel>() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(TutorTabViewModel tutorTabViewModel) {
|
||||||
|
|
||||||
|
List<String> dutyHoursList = Stream.of(tutorTabViewModel.getDutyHours())
|
||||||
|
.map(DutyHourViewModel::getSummary).toList();
|
||||||
|
|
||||||
|
userRoom.setText(String.format("%s: %s", getString(R.string.userRoom), tutorTabViewModel.getRoom()));
|
||||||
|
userEmail.setText(String.format("%s: %s", getString(R.string.userEmail), tutorTabViewModel.getEmailTutorTab()));
|
||||||
|
if (!tutorTabViewModel.getNote().equals("")) {
|
||||||
|
userNote.setText(String.format("%s", tutorTabViewModel.getNote()));
|
||||||
|
}
|
||||||
|
userDutyHours.setText(String.format("%s: %s", getString(R.string.userDutyHoursHeader), Arrays.toString(dutyHoursList.toArray())));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(Throwable e) {
|
||||||
|
showError(e);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
disposable.add(
|
||||||
|
|
||||||
|
userService.getUserById(PrefUtils.getUserId(getApplicationContext()))
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribeWith(new DisposableSingleObserver<User>() {
|
.subscribeWith(new DisposableSingleObserver<User>() {
|
||||||
@ -112,143 +102,34 @@ public class TutorTab extends AppCompatActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(Throwable e) {
|
public void onError(Throwable e) {
|
||||||
|
|
||||||
showError(e);
|
showError(e);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
setUpSaveListener(saveButon);
|
setUpSaveListener(saveButon, userNote);
|
||||||
scrapButton.setOnClickListener(view -> scrapTutorTab());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void setUpSaveListener(Button button, EditText note) {
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
button.setOnClickListener(new View.OnClickListener() {
|
||||||
getMenuInflater().inflate(R.menu.menu_profile, menu);
|
@Override
|
||||||
return true;
|
public void onClick(View view) {
|
||||||
}
|
newTab = new TutorTabViewModel(PrefUtils.getUserId(getApplicationContext()),note.getText().toString());
|
||||||
|
putUserTab(newTab);
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
|
|
||||||
if (item.getItemId()==R.id.action_profile_info_popup){
|
|
||||||
int layoutID = R.layout.info_popup_tutor_tab;
|
|
||||||
|
|
||||||
View popupView = getLayoutInflater().inflate(layoutID,null);
|
|
||||||
|
|
||||||
PopupWindow popupWindow = new PopupWindow(popupView,
|
|
||||||
LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
|
|
||||||
// If the PopupWindow should be focusable
|
|
||||||
popupWindow.setFocusable(true);
|
|
||||||
// If you need the PopupWindow to dismiss when when touched outside
|
|
||||||
popupWindow.setBackgroundDrawable(new ColorDrawable());
|
|
||||||
// Get the View's(the one that was clicked in the Fragment) location
|
|
||||||
View anchorView= getWindow().getDecorView().findViewById(android.R.id.content);
|
|
||||||
popupWindow.showAtLocation(anchorView,Gravity.TOP|Gravity.END, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.onOptionsItemSelected(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void getTutorTab(){
|
|
||||||
disposable.add(
|
|
||||||
tutorTabService.apiUsersTutorTabByTutorIdGet(PrefUtils.getUserId(getApplicationContext()))
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribeWith(new DisposableSingleObserver<TutorTabViewModel>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(TutorTabViewModel tutorTabViewModel) {
|
|
||||||
|
|
||||||
dutyHourList = tutorTabViewModel.getDutyHours();
|
|
||||||
if(dutyHourList != null){
|
|
||||||
dutyHoursAdapter = new DutyHoursAdapter(getApplicationContext(),dutyHourList, getFragmentManager());
|
|
||||||
dutyHoursRecycller.setAdapter(dutyHoursAdapter);
|
|
||||||
addDutyButton.setOnClickListener(v -> addEmptyDuty(dutyHoursAdapter));
|
|
||||||
}
|
|
||||||
userRoom.setText(String.format("%s", tutorTabViewModel.getRoom()));
|
|
||||||
userEmail.setText(String.format("%s", tutorTabViewModel.getEmailTutorTab()));
|
|
||||||
if (!tutorTabViewModel.getNote().equals("")) {
|
|
||||||
userNote.setText(String.format("%s", tutorTabViewModel.getNote()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(Throwable e) {
|
|
||||||
int code = 0;
|
|
||||||
|
|
||||||
if (e instanceof HttpException) {
|
|
||||||
code = ((HttpException) e).response().code();
|
|
||||||
}
|
|
||||||
|
|
||||||
if( code == 404){
|
|
||||||
ifTutorTabExists = false;
|
|
||||||
dutyHoursAdapter = new DutyHoursAdapter(getApplicationContext(),new ArrayList<DutyHourViewModel>(), getFragmentManager());
|
|
||||||
dutyHoursRecycller.setAdapter(dutyHoursAdapter);
|
|
||||||
addDutyButton.setOnClickListener(v -> addEmptyDuty(dutyHoursAdapter));
|
|
||||||
}
|
|
||||||
showError(e);
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addEmptyDuty(DutyHoursAdapter adapter){
|
|
||||||
adapter.addDuty(new DutyHourViewModel());
|
|
||||||
adapter.notifyItemInserted(adapter.getItemCount());
|
|
||||||
dutyHoursRecycller.scrollToPosition(adapter.getItemCount()-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setUpSaveListener(Button button) {
|
|
||||||
button.setOnClickListener(view -> {
|
|
||||||
if( isEmailValid(userEmail.getText().toString())){
|
|
||||||
newTab = new TutorTabViewModel(PrefUtils.getUserId(getApplicationContext()),
|
|
||||||
userRoom.getText().toString(),
|
|
||||||
userEmail.getText().toString(),
|
|
||||||
userNote.getText().toString(),
|
|
||||||
dutyHoursAdapter.getDutyList());
|
|
||||||
if(ifTutorTabExists){
|
|
||||||
putUserTab(newTab);
|
|
||||||
}else{
|
|
||||||
postUserTab(newTab);
|
|
||||||
ifTutorTabExists=true;
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
userEmail.setError(getString(R.string.error_invalid_email));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void putUserTab(TutorTabViewModel tutorTabViewModel) {
|
private void putUserTab(TutorTabViewModel tutorTabViewModel) {
|
||||||
disposable.add(tutorTabService.apiUsersTutorTabByTutorIdPut(PrefUtils.getUserId(getApplicationContext()), tutorTabViewModel)
|
disposable.add(tutorTabService.apiUsersTutorTabByTutorIdPut(PrefUtils.getUserId(getApplicationContext()), tutorTabViewModel)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(this::handleResponsePut, this::handleError));
|
.subscribe(this::handleResponse, this::handleError));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void postUserTab(TutorTabViewModel tutorTabViewModel) {
|
private void handleResponse(TutorTabViewModel tutorTabViewModel) {
|
||||||
disposable.add(tutorTabService.apiUsersTutorTabByTutorIdPost(PrefUtils.getUserId(getApplicationContext()), tutorTabViewModel)
|
Toast.makeText(getApplicationContext(), getApplicationContext().getString(R.string.modal_feedback_thankyou), Toast.LENGTH_SHORT).show();
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribe(this::handleResponsePost, this::handleError));
|
|
||||||
}
|
|
||||||
private void scrapTutorTab() {
|
|
||||||
|
|
||||||
disposable.add(tutorTabService.apiUsersScrapTutorTabByTutorIdPost(PrefUtils.getUserId(getApplicationContext()))
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribe(this::handleResponseScrap, this::handleError));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleResponseScrap() {
|
|
||||||
Toast.makeText(getApplicationContext(), getApplicationContext().getString(R.string.scrap_tutor_msg), Toast.LENGTH_SHORT).show();
|
|
||||||
getTutorTab();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleResponsePut(Response<Void> resp) {
|
|
||||||
Toast.makeText(getApplicationContext(), getApplicationContext().getString(R.string.updateToast), Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleResponsePost(TutorTabViewModel tutorTabViewModel ) {
|
|
||||||
Toast.makeText(getApplicationContext(), getApplicationContext().getString(R.string.updateToast), Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleError(Throwable error) {
|
private void handleError(Throwable error) {
|
||||||
if (error instanceof HttpException) {
|
if (error instanceof HttpException) {
|
||||||
@ -260,9 +141,6 @@ public class TutorTab extends AppCompatActivity {
|
|||||||
} else {
|
} else {
|
||||||
Toast.makeText(getApplicationContext(),
|
Toast.makeText(getApplicationContext(),
|
||||||
"Network error " + error.getMessage(), Toast.LENGTH_SHORT).show();
|
"Network error " + error.getMessage(), Toast.LENGTH_SHORT).show();
|
||||||
|
|
||||||
Log.e("WMI SUCC", String.valueOf(error));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,29 +153,10 @@ public class TutorTab extends AppCompatActivity {
|
|||||||
} else {
|
} else {
|
||||||
message = "Network Error!";
|
message = "Network Error!";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Snackbar.make(coordinatorLayout, message, Snackbar.LENGTH_LONG)
|
||||||
|
// .show();
|
||||||
Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show();
|
Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void attachBaseContext(Context base) {
|
|
||||||
super.attachBaseContext(LocaleHelper.onAttach(base));
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEmailValid(String email)
|
|
||||||
{
|
|
||||||
String regExpn =
|
|
||||||
"^(([\\w-]+\\.)+[\\w-]+|([a-zA-Z]{1}|[\\w-]{2,}))@"
|
|
||||||
+"((([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\\.([0-1]?"
|
|
||||||
+"[0-9]{1,2}|25[0-5]|2[0-4][0-9])\\."
|
|
||||||
+"([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\\.([0-1]?"
|
|
||||||
+"[0-9]{1,2}|25[0-5]|2[0-4][0-9])){1}|"
|
|
||||||
+"([a-zA-Z]+[\\w-]+\\.)+[a-zA-Z]{2,4})$";
|
|
||||||
|
|
||||||
CharSequence inputStr = email;
|
|
||||||
|
|
||||||
Pattern pattern = Pattern.compile(regExpn,Pattern.CASE_INSENSITIVE);
|
|
||||||
Matcher matcher = pattern.matcher(inputStr);
|
|
||||||
|
|
||||||
return matcher.matches();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,46 +0,0 @@
|
|||||||
package com.uam.wmi.findmytutor.activity;
|
|
||||||
|
|
||||||
//import android.app.Fragment;
|
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.v4.app.FragmentTabHost;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
|
|
||||||
import com.uam.wmi.findmytutor.R;
|
|
||||||
|
|
||||||
public class TutorsListTab extends Fragment {
|
|
||||||
private FragmentTabHost mTabHost;
|
|
||||||
|
|
||||||
public TutorsListTab() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static TutorsListTab newInstance() {
|
|
||||||
return new TutorsListTab();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
|
||||||
Bundle savedInstanceState) {
|
|
||||||
|
|
||||||
View rootView = inflater.inflate(R.layout.tutors_list_tabs, container, false);
|
|
||||||
|
|
||||||
mTabHost = rootView.findViewById(android.R.id.tabhost);
|
|
||||||
mTabHost.setup(getActivity(), getFragmentManager(), R.id.realtabcontent);
|
|
||||||
|
|
||||||
mTabHost.addTab(mTabHost.newTabSpec("fragmentb").setIndicator("Fragment B"),
|
|
||||||
UsersListFragment.class, null);
|
|
||||||
mTabHost.addTab(mTabHost.newTabSpec("fragmentc").setIndicator("Fragment C"),
|
|
||||||
UsersListFragment.class, null);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return rootView;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,10 +1,7 @@
|
|||||||
package com.uam.wmi.findmytutor.activity;
|
package com.uam.wmi.findmytutor.activity;
|
||||||
|
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
import android.app.FragmentTransaction;
|
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.SystemClock;
|
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.design.widget.CoordinatorLayout;
|
import android.support.design.widget.CoordinatorLayout;
|
||||||
import android.support.design.widget.Snackbar;
|
import android.support.design.widget.Snackbar;
|
||||||
@ -12,60 +9,38 @@ import android.support.v7.app.AlertDialog;
|
|||||||
import android.support.v7.widget.DefaultItemAnimator;
|
import android.support.v7.widget.DefaultItemAnimator;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.support.v7.widget.SearchView;
|
|
||||||
import android.text.Spannable;
|
|
||||||
import android.text.SpannableString;
|
|
||||||
import android.text.format.DateFormat;
|
|
||||||
import android.text.style.ImageSpan;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.Gravity;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuInflater;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.annimon.stream.Stream;
|
import com.annimon.stream.Stream;
|
||||||
import com.github.ybq.android.spinkit.SpinKitView;
|
|
||||||
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
|
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
|
||||||
import com.uam.wmi.findmytutor.R;
|
import com.uam.wmi.findmytutor.R;
|
||||||
import com.uam.wmi.findmytutor.adapters.TutorsListAdapter;
|
import com.uam.wmi.findmytutor.adapters.TutorsListAdapter;
|
||||||
import com.uam.wmi.findmytutor.model.Coordinate;
|
|
||||||
import com.uam.wmi.findmytutor.model.DutyHourViewModel;
|
import com.uam.wmi.findmytutor.model.DutyHourViewModel;
|
||||||
import com.uam.wmi.findmytutor.model.TutorTabViewModel;
|
import com.uam.wmi.findmytutor.model.TutorTabViewModel;
|
||||||
import com.uam.wmi.findmytutor.model.User;
|
import com.uam.wmi.findmytutor.model.User;
|
||||||
import com.uam.wmi.findmytutor.network.ApiClient;
|
import com.uam.wmi.findmytutor.network.ApiClient;
|
||||||
import com.uam.wmi.findmytutor.service.CoordinateService;
|
|
||||||
import com.uam.wmi.findmytutor.service.TutorTabApi;
|
import com.uam.wmi.findmytutor.service.TutorTabApi;
|
||||||
import com.uam.wmi.findmytutor.service.UserService;
|
import com.uam.wmi.findmytutor.service.UserService;
|
||||||
import com.uam.wmi.findmytutor.utils.ActiveFragment;
|
|
||||||
import com.uam.wmi.findmytutor.utils.MyDividerItemDecoration;
|
import com.uam.wmi.findmytutor.utils.MyDividerItemDecoration;
|
||||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
|
||||||
import com.uam.wmi.findmytutor.utils.RecyclerTouchListener;
|
import com.uam.wmi.findmytutor.utils.RecyclerTouchListener;
|
||||||
import com.uam.wmi.findmytutor.utils.RestApiHelper;
|
import com.uam.wmi.findmytutor.utils.RestApiHelper;
|
||||||
|
|
||||||
import java.text.Collator;
|
import java.text.Collator;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import io.reactivex.Observable;
|
|
||||||
import io.reactivex.ObservableSource;
|
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
import io.reactivex.disposables.Disposable;
|
|
||||||
import io.reactivex.functions.Function;
|
|
||||||
import io.reactivex.observers.DisposableObserver;
|
|
||||||
import io.reactivex.observers.DisposableSingleObserver;
|
import io.reactivex.observers.DisposableSingleObserver;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
import io.reactivex.schedulers.Schedulers;
|
||||||
import okhttp3.ResponseBody;
|
import okhttp3.ResponseBody;
|
||||||
@ -81,20 +56,14 @@ public class UsersListFragment extends Fragment {
|
|||||||
RecyclerView recyclerView;
|
RecyclerView recyclerView;
|
||||||
@BindView(R.id.txt_empty_notes_view)
|
@BindView(R.id.txt_empty_notes_view)
|
||||||
TextView noNotesView;
|
TextView noNotesView;
|
||||||
@BindView(R.id.loader)
|
|
||||||
SpinKitView loader;
|
|
||||||
|
|
||||||
private SearchView searchView;
|
|
||||||
private UserService userService;
|
private UserService userService;
|
||||||
private TutorTabApi tutorTabService;
|
private TutorTabApi tutorTabService;
|
||||||
private CoordinateService coordinateService;
|
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
private TutorsListAdapter mAdapter;
|
private TutorsListAdapter mAdapter;
|
||||||
private List<User> tutorsList = new ArrayList<>();
|
private List<User> tutorsList = new ArrayList<>();
|
||||||
private HashMap<String, String> tutorsTimeStamps = new HashMap<>();
|
private List<User> tutorsFiltered = new ArrayList<>();
|
||||||
|
|
||||||
private Collator plCollator = Collator.getInstance(Locale.forLanguageTag("pl-PL"));
|
private Collator plCollator = Collator.getInstance(Locale.forLanguageTag("pl-PL"));
|
||||||
private Boolean fetchOnlyOnlineUsers = PrefUtils.getShowOnlyOnlineUsers(getApplicationContext());
|
|
||||||
|
|
||||||
public UsersListFragment() {
|
public UsersListFragment() {
|
||||||
}
|
}
|
||||||
@ -104,10 +73,9 @@ public class UsersListFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
mAdapter = new TutorsListAdapter(getActivity().getApplicationContext(), tutorsList, tutorsTimeStamps);
|
mAdapter = new TutorsListAdapter(getActivity().getApplicationContext(), tutorsFiltered);
|
||||||
View view = inflater.inflate(R.layout.users_list, container, false);
|
View view = inflater.inflate(R.layout.users_list, container, false);
|
||||||
view.setBackgroundColor(getResources().getColor(android.R.color.white));
|
view.setBackgroundColor(getResources().getColor(android.R.color.white));
|
||||||
setHasOptionsMenu(true);
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,27 +84,23 @@ public class UsersListFragment extends Fragment {
|
|||||||
|
|
||||||
userService = ApiClient.getClient(getApplicationContext())
|
userService = ApiClient.getClient(getApplicationContext())
|
||||||
.create(UserService.class);
|
.create(UserService.class);
|
||||||
|
|
||||||
tutorTabService = ApiClient.getClient(getActivity().getApplicationContext())
|
tutorTabService = ApiClient.getClient(getActivity().getApplicationContext())
|
||||||
.create(TutorTabApi.class);
|
.create(TutorTabApi.class);
|
||||||
coordinateService = ApiClient.getClient(getApplicationContext())
|
|
||||||
.create(CoordinateService.class);
|
|
||||||
|
|
||||||
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getActivity());
|
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getActivity());
|
||||||
recyclerView.setLayoutManager(mLayoutManager);
|
recyclerView.setLayoutManager(mLayoutManager);
|
||||||
recyclerView.setItemAnimator(new DefaultItemAnimator());
|
recyclerView.setItemAnimator(new DefaultItemAnimator());
|
||||||
recyclerView.setVerticalScrollBarEnabled(true);
|
|
||||||
recyclerView.addItemDecoration(new MyDividerItemDecoration(getActivity(), LinearLayoutManager.VERTICAL, 16));
|
recyclerView.addItemDecoration(new MyDividerItemDecoration(getActivity(), LinearLayoutManager.VERTICAL, 16));
|
||||||
recyclerView.setAdapter(mAdapter);
|
recyclerView.setAdapter(mAdapter);
|
||||||
noNotesView.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
fetchAllTutors();
|
fetchAllTutors();
|
||||||
fetchTopCords();
|
|
||||||
|
|
||||||
recyclerView.addOnItemTouchListener(new RecyclerTouchListener(getActivity().getApplicationContext(),
|
recyclerView.addOnItemTouchListener(new RecyclerTouchListener(getActivity().getApplicationContext(),
|
||||||
recyclerView, new RecyclerTouchListener.ClickListener() {
|
recyclerView, new RecyclerTouchListener.ClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view, final int position) {
|
public void onClick(View view, final int position) {
|
||||||
showNoteDialog(tutorsList.get(position));
|
showNoteDialog(tutorsFiltered.get(position));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -146,52 +110,12 @@ public class UsersListFragment extends Fragment {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPrepareOptionsMenu(Menu menu) {
|
|
||||||
super.onPrepareOptionsMenu(menu);
|
|
||||||
try {
|
|
||||||
menu.findItem(R.id.showOnlineUsersOnly).setChecked(fetchOnlyOnlineUsers);
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.e(TAG, "onPrepareOptionsMenu error");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
//item.setChecked(fetchOnlyOnlineUsers);
|
|
||||||
switch (item.getItemId()) {
|
|
||||||
case R.id.showOnlineUsersOnly:
|
|
||||||
|
|
||||||
if (item.isChecked()) {
|
|
||||||
fetchOnlyOnlineUsers = false;
|
|
||||||
item.setChecked(false);
|
|
||||||
} else {
|
|
||||||
item.setChecked(true);
|
|
||||||
fetchOnlyOnlineUsers = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
PrefUtils.putShowOnlyOnlineUsers(getApplicationContext(), fetchOnlyOnlineUsers);
|
|
||||||
fetchAllTutors();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
|
||||||
inflater.inflate(R.menu.users_list_menu, menu);
|
|
||||||
menu.getItem(0).setChecked(fetchOnlyOnlineUsers);
|
|
||||||
|
|
||||||
MenuItem myActionMenuItem = menu.findItem(R.id.action_search);
|
|
||||||
searchView = (SearchView) myActionMenuItem.getActionView();
|
|
||||||
|
|
||||||
super.onCreateOptionsMenu(menu, inflater);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void searchUser(String textToSearch) {
|
public void searchUser(String textToSearch) {
|
||||||
searchTutorInBackend(textToSearch);
|
|
||||||
|
tutorsFiltered.clear();
|
||||||
|
tutorsFiltered.addAll(Stream.of(tutorsList).filter(t ->
|
||||||
|
t.toSearchAbleString().toLowerCase().contains(textToSearch.toLowerCase())).toList());
|
||||||
|
mAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showNoteDialog(final User user) {
|
private void showNoteDialog(final User user) {
|
||||||
@ -205,7 +129,6 @@ public class UsersListFragment extends Fragment {
|
|||||||
// User cancelled the dialog
|
// User cancelled the dialog
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
TextView userName = view.findViewById(R.id.userName);
|
TextView userName = view.findViewById(R.id.userName);
|
||||||
ListView userDutyHours = view.findViewById(R.id.userDutyHours);
|
ListView userDutyHours = view.findViewById(R.id.userDutyHours);
|
||||||
TextView userDutyHoursTitle = view.findViewById(R.id.userDutyHoursTitle);
|
TextView userDutyHoursTitle = view.findViewById(R.id.userDutyHoursTitle);
|
||||||
@ -213,30 +136,9 @@ public class UsersListFragment extends Fragment {
|
|||||||
TextView userRoom = view.findViewById(R.id.userRoom);
|
TextView userRoom = view.findViewById(R.id.userRoom);
|
||||||
TextView userEmail = view.findViewById(R.id.userEmail);
|
TextView userEmail = view.findViewById(R.id.userEmail);
|
||||||
TextView department = view.findViewById(R.id.userDepartment);
|
TextView department = view.findViewById(R.id.userDepartment);
|
||||||
TextView userStatusLabel = view.findViewById(R.id.user_status_label);
|
|
||||||
LinearLayout userStatusLabelLL = view.findViewById(R.id.user_status_label_linearLayout);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
userName.setText(String.format("%s %s", user.getFirstName(), user.getLastName()));
|
userName.setText(String.format("%s %s", user.getFirstName(), user.getLastName()));
|
||||||
Drawable image;
|
|
||||||
if (user.isIsOnline()) {
|
|
||||||
image = this.getResources().getDrawable(R.drawable.user_list_online);
|
|
||||||
} else {
|
|
||||||
image = this.getResources().getDrawable(R.drawable.user_list_offline);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!user.isIsActive()) {
|
|
||||||
image = this.getResources().getDrawable(R.drawable.user_list_off);
|
|
||||||
}
|
|
||||||
|
|
||||||
Spannable span = new SpannableString(" " + userName.getText()); // or set your text manually
|
|
||||||
image.setBounds(0, 0, image.getIntrinsicWidth(), image.getIntrinsicHeight());
|
|
||||||
ImageSpan imageSpan = new ImageSpan(image);
|
|
||||||
span.setSpan(imageSpan, 0, 1, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
|
||||||
userName.setText(span);
|
|
||||||
|
|
||||||
UsersListFragment usersListFragment = this;
|
|
||||||
disposable.add(
|
disposable.add(
|
||||||
tutorTabService.apiUsersTutorTabByTutorIdGet(user.getId())
|
tutorTabService.apiUsersTutorTabByTutorIdGet(user.getId())
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
@ -244,30 +146,16 @@ public class UsersListFragment extends Fragment {
|
|||||||
.subscribeWith(new DisposableSingleObserver<TutorTabViewModel>() {
|
.subscribeWith(new DisposableSingleObserver<TutorTabViewModel>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(TutorTabViewModel tutorTabViewModel) {
|
public void onSuccess(TutorTabViewModel tutorTabViewModel) {
|
||||||
final AlertDialog alertDialog;
|
final AlertDialog alertDialog = alertDialogBuilderUserInput.create();
|
||||||
if (((MapActivity) getActivity()).coordsMap.containsKey(user.getId())) {
|
|
||||||
|
|
||||||
alertDialogBuilderUserInput.setPositiveButton(R.string.show_on_map, (dialog, id) -> {
|
|
||||||
// User cancelled the dialog
|
|
||||||
((MapActivity) getActivity()).activeFragment = ActiveFragment.NONE;
|
|
||||||
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
|
|
||||||
fragmentTransaction.hide(usersListFragment);
|
|
||||||
fragmentTransaction.commit();
|
|
||||||
((MapActivity) getActivity()).searchUser(user.getFirstName());
|
|
||||||
((MapActivity) getActivity()).updateNavigationBarState();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
alertDialog = alertDialogBuilderUserInput.create();
|
|
||||||
|
|
||||||
String userNoteText = tutorTabViewModel.getNote();
|
String userNoteText = tutorTabViewModel.getNote();
|
||||||
List<String> dutyHoursList = Stream.of(tutorTabViewModel.getDutyHours())
|
List<String> dutyHoursList = Stream.of(tutorTabViewModel.getDutyHours())
|
||||||
.map(DutyHourViewModel::getSummary).toList();
|
.map(DutyHourViewModel::getSummary).toList();
|
||||||
|
|
||||||
if (dutyHoursList.isEmpty()) {
|
if(dutyHoursList.isEmpty()){
|
||||||
dutyHoursList.add(getString(R.string.lack_duty_hours));
|
dutyHoursList.add(getString(R.string.lack_duty_hours));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tutorTabViewModel.getNote().isEmpty()) {
|
if(tutorTabViewModel.getNote().isEmpty()){
|
||||||
userNoteText = getString(R.string.lack_note);
|
userNoteText = getString(R.string.lack_note);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,16 +165,6 @@ public class UsersListFragment extends Fragment {
|
|||||||
department.setText(String.format("%s: %s", getString(R.string.userDepartment), user.getDepartment()));
|
department.setText(String.format("%s: %s", getString(R.string.userDepartment), user.getDepartment()));
|
||||||
userDutyHoursTitle.setText(String.format("%s:", getString(R.string.userDutyHoursHeader)));
|
userDutyHoursTitle.setText(String.format("%s:", getString(R.string.userDutyHoursHeader)));
|
||||||
|
|
||||||
Coordinate coordinate = ((MapActivity) getActivity()).coordsMap.get(user.getId());
|
|
||||||
if (coordinate != null){
|
|
||||||
String label = coordinate.getLabel();
|
|
||||||
if (!label.isEmpty()) {
|
|
||||||
userStatusLabelLL.setVisibility(View.VISIBLE);
|
|
||||||
userStatusLabel.setText(String.format("%s: %s", getString(R.string.user_status_label),label));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(getActivity(),
|
final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(getActivity(),
|
||||||
R.layout.duty_hours_item, dutyHoursList);
|
R.layout.duty_hours_item, dutyHoursList);
|
||||||
|
|
||||||
@ -304,20 +182,38 @@ public class UsersListFragment extends Fragment {
|
|||||||
|
|
||||||
private void fetchAllTutors() {
|
private void fetchAllTutors() {
|
||||||
disposable.add(
|
disposable.add(
|
||||||
(fetchOnlyOnlineUsers ?
|
userService.getAllTutors()
|
||||||
userService.getAllActiveTutors() :
|
|
||||||
userService.getAllTutors())
|
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.map(this::mapUsersToSortedList)
|
.map(tutors -> {
|
||||||
|
List<User> tutorsList = new ArrayList<>(tutors);
|
||||||
|
|
||||||
|
List<User> onlineTutors = Stream.of(tutorsList).filter(User::isIsOnline).toList();
|
||||||
|
|
||||||
|
List<User> activeNotOnlineTutors = Stream.of(tutorsList)
|
||||||
|
.filter(t -> t.isIsActive() && !onlineTutors.contains(t)).toList();
|
||||||
|
|
||||||
|
List<User> notActiveTutors = Stream.of(tutorsList)
|
||||||
|
.filterNot(User::isIsActive).toList();
|
||||||
|
|
||||||
|
Collections.sort(onlineTutors, this::sortByUserName);
|
||||||
|
Collections.sort(activeNotOnlineTutors, this::sortByUserName);
|
||||||
|
Collections.sort(notActiveTutors, this::sortByUserName);
|
||||||
|
|
||||||
|
List<User> sortedUserList = new ArrayList<>(onlineTutors);
|
||||||
|
sortedUserList.addAll(activeNotOnlineTutors);
|
||||||
|
sortedUserList.addAll(notActiveTutors);
|
||||||
|
|
||||||
|
return sortedUserList;
|
||||||
|
})
|
||||||
.subscribeWith(new DisposableSingleObserver<List<User>>() {
|
.subscribeWith(new DisposableSingleObserver<List<User>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(List<User> users) {
|
public void onSuccess(List<User> users) {
|
||||||
tutorsList.clear();
|
tutorsList.clear();
|
||||||
tutorsList.addAll(users);
|
tutorsList.addAll(users);
|
||||||
|
tutorsFiltered.addAll(users);
|
||||||
mAdapter.notifyDataSetChanged();
|
mAdapter.notifyDataSetChanged();
|
||||||
toggleEmptyNotes();
|
toggleEmptyNotes();
|
||||||
fetchTopCords();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -327,135 +223,33 @@ public class UsersListFragment extends Fragment {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<User> mapUsersToSortedList(List<User> tutors) {
|
|
||||||
List<User> tutorsList = new ArrayList<>(tutors);
|
|
||||||
List<User> onlineTutors = Stream.of(tutorsList).filter(User::isIsOnline).toList();
|
|
||||||
List<User> activeNotOnlineTutors = Stream.of(tutorsList)
|
|
||||||
.filter(t -> t.isIsActive() && !onlineTutors.contains(t)).toList();
|
|
||||||
List<User> notActiveTutors = Stream.of(tutorsList)
|
|
||||||
.filterNot(User::isIsActive).toList();
|
|
||||||
|
|
||||||
Collections.sort(onlineTutors, this::sortByUserName);
|
|
||||||
Collections.sort(activeNotOnlineTutors, this::sortByUserName);
|
|
||||||
Collections.sort(notActiveTutors, this::sortByUserName);
|
|
||||||
|
|
||||||
List<User> sortedUserList = new ArrayList<>(onlineTutors);
|
|
||||||
sortedUserList.addAll(activeNotOnlineTutors);
|
|
||||||
sortedUserList.addAll(notActiveTutors);
|
|
||||||
|
|
||||||
return sortedUserList;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void searchTutorInBackend(String searchString) {
|
|
||||||
disposable.add(
|
|
||||||
userService.searchUser(searchString)
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribeWith(new DisposableSingleObserver<List<User>>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(List<User> users) {
|
|
||||||
tutorsList.clear();
|
|
||||||
tutorsList.addAll(users);
|
|
||||||
mAdapter.notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(Throwable e) {
|
|
||||||
showSearchError(e);
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void restoreUsersList() {
|
|
||||||
fetchAllTutors();
|
|
||||||
fetchTopCords();
|
|
||||||
}
|
|
||||||
|
|
||||||
private int sortByUserName(User t1, User t2) {
|
private int sortByUserName(User t1, User t2) {
|
||||||
return plCollator.compare(t1.getLastName(), t2.getLastName());
|
return plCollator.compare(t1.getLastName(),t2.getLastName());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showError(Throwable e) {
|
private void showError(Throwable e) {
|
||||||
String message;
|
String message;
|
||||||
Log.e(TAG, String.valueOf(e));
|
|
||||||
|
|
||||||
if (e instanceof HttpException) {
|
if (e instanceof HttpException) {
|
||||||
ResponseBody responseBody = ((HttpException) e).response().errorBody();
|
ResponseBody responseBody = ((HttpException) e).response().errorBody();
|
||||||
message = RestApiHelper.getErrorMessage(responseBody);
|
message = RestApiHelper.getErrorMessage(responseBody);
|
||||||
} else {
|
}else{
|
||||||
message = getString(R.string.network_err);
|
message = "Network Error !";
|
||||||
}
|
}
|
||||||
|
|
||||||
createSnackbar(message);
|
Snackbar.make(coordinatorLayout, message, Snackbar.LENGTH_LONG)
|
||||||
}
|
.show();
|
||||||
|
|
||||||
private void showSearchError(Throwable e) {
|
|
||||||
String message;
|
|
||||||
Log.e(TAG, String.valueOf(e));
|
|
||||||
|
|
||||||
if (e instanceof HttpException) {
|
|
||||||
ResponseBody responseBody = ((HttpException) e).response().errorBody();
|
|
||||||
message = RestApiHelper.getErrorMessage(responseBody);
|
|
||||||
} else {
|
|
||||||
message = getString(R.string.search_null);
|
|
||||||
}
|
|
||||||
|
|
||||||
createSnackbar(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createSnackbar(String msg) {
|
|
||||||
Snackbar snackbar = Snackbar.make(coordinatorLayout, msg, Snackbar.LENGTH_LONG);
|
|
||||||
View view = snackbar.getView();
|
|
||||||
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) view.getLayoutParams();
|
|
||||||
params.gravity = Gravity.TOP;
|
|
||||||
view.setLayoutParams(params);
|
|
||||||
snackbar.show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void toggleEmptyNotes() {
|
private void toggleEmptyNotes() {
|
||||||
loader.setVisibility(View.GONE);
|
if (tutorsList.size() > 0) {
|
||||||
noNotesView.setVisibility(View.GONE);
|
noNotesView.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
if (tutorsList.size() == 0) {
|
|
||||||
noNotesView.setVisibility(View.VISIBLE);
|
noNotesView.setVisibility(View.VISIBLE);
|
||||||
if (fetchOnlyOnlineUsers)
|
|
||||||
noNotesView.setText(R.string.no_online_users);
|
|
||||||
else {
|
|
||||||
noNotesView.setText(R.string.no_offline_users);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void onSaveInstanceState(Bundle outState) {
|
|
||||||
super.onSaveInstanceState(outState);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void fetchTopCords(){
|
|
||||||
disposable.add(
|
|
||||||
coordinateService.getTopCoordinates()
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribe(this::addTimestamps,this::showError));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addTimestamps(List<Coordinate> coordinates) {
|
|
||||||
for (Coordinate crd :
|
|
||||||
coordinates) {
|
|
||||||
Long ts = crd.getTimeStamp();
|
|
||||||
tutorsTimeStamps.put(crd.getUserId(), getDate(ts));
|
|
||||||
}
|
|
||||||
|
|
||||||
mAdapter.notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getDate(long time) {
|
|
||||||
Calendar cal = Calendar.getInstance(Locale.ENGLISH);
|
|
||||||
cal.setTimeInMillis(time);
|
|
||||||
return DateFormat.format("HH:mm dd/MM", cal).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
@ -478,4 +272,7 @@ public class UsersListFragment extends Fragment {
|
|||||||
super.onStop();
|
super.onStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
public void onSaveInstanceState(Bundle outState) {
|
||||||
|
super.onSaveInstanceState(outState);
|
||||||
|
}
|
||||||
|
}
|
@ -1,363 +0,0 @@
|
|||||||
package com.uam.wmi.findmytutor.activity;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.drawable.ColorDrawable;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.annotation.RequiresApi;
|
|
||||||
import android.support.design.widget.FloatingActionButton;
|
|
||||||
import android.support.design.widget.Snackbar;
|
|
||||||
import android.support.v7.app.AlertDialog;
|
|
||||||
import android.support.v7.app.AppCompatActivity;
|
|
||||||
import android.support.v7.widget.DefaultItemAnimator;
|
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
|
||||||
import android.support.v7.widget.RecyclerView;
|
|
||||||
import android.support.v7.widget.Toolbar;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.Gravity;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.EditText;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.PopupWindow;
|
|
||||||
import android.widget.Switch;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.github.ybq.android.spinkit.SpinKitView;
|
|
||||||
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
|
|
||||||
import com.uam.wmi.findmytutor.R;
|
|
||||||
import com.uam.wmi.findmytutor.adapters.WhiteListAdapter;
|
|
||||||
import com.uam.wmi.findmytutor.model.IsUsingListBool;
|
|
||||||
import com.uam.wmi.findmytutor.model.StudentIdModel;
|
|
||||||
import com.uam.wmi.findmytutor.model.User;
|
|
||||||
import com.uam.wmi.findmytutor.network.ApiClient;
|
|
||||||
import com.uam.wmi.findmytutor.service.UserService;
|
|
||||||
import com.uam.wmi.findmytutor.utils.LocaleHelper;
|
|
||||||
import com.uam.wmi.findmytutor.utils.MyDividerItemDecoration;
|
|
||||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
|
||||||
import com.uam.wmi.findmytutor.utils.RecyclerTouchListener;
|
|
||||||
import com.uam.wmi.findmytutor.utils.RestApiHelper;
|
|
||||||
import com.uam.wmi.findmytutor.utils.WrapContentLinearLayoutManager;
|
|
||||||
|
|
||||||
import java.text.Collator;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import io.reactivex.Observable;
|
|
||||||
import io.reactivex.ObservableSource;
|
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
|
||||||
import io.reactivex.disposables.Disposable;
|
|
||||||
import io.reactivex.functions.Function;
|
|
||||||
import io.reactivex.observers.DisposableObserver;
|
|
||||||
import io.reactivex.schedulers.Schedulers;
|
|
||||||
import okhttp3.ResponseBody;
|
|
||||||
|
|
||||||
public class WhiteList extends AppCompatActivity {
|
|
||||||
|
|
||||||
@BindView(R.id.recycler_view_whitelist)
|
|
||||||
RecyclerView recyclerView;
|
|
||||||
@BindView(R.id.white_list_empty_text_view)
|
|
||||||
TextView noNotesView;
|
|
||||||
@BindView(R.id.switch_whitelist_toggle)
|
|
||||||
Switch aSwitch;
|
|
||||||
@BindView(R.id.add_to_white_list_fab)
|
|
||||||
FloatingActionButton addToWhiteListFab;
|
|
||||||
|
|
||||||
@BindView(R.id.loader)
|
|
||||||
SpinKitView loader;
|
|
||||||
|
|
||||||
|
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
|
||||||
private UserService userService;
|
|
||||||
private boolean didFetched = false;
|
|
||||||
private String tutorId;
|
|
||||||
private WhiteListAdapter mAdapter;
|
|
||||||
private Integer prevSize;
|
|
||||||
private List<User> whitelistedUsers = new ArrayList<>();
|
|
||||||
private Collator plCollator = Collator.getInstance(Locale.forLanguageTag("pl-PL"));
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void attachBaseContext(Context base) {
|
|
||||||
super.attachBaseContext(LocaleHelper.onAttach(base));
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
|
||||||
setContentView(R.layout.activity_white_list);
|
|
||||||
ButterKnife.bind(this);
|
|
||||||
|
|
||||||
tutorId = PrefUtils.getUserId(getApplicationContext());
|
|
||||||
userService = ApiClient.getClient(getApplicationContext())
|
|
||||||
.create(UserService.class);
|
|
||||||
|
|
||||||
if (PrefUtils.isWhiteListing(this)) {
|
|
||||||
aSwitch.setText(getString(R.string.action_white_list) +" "+getString(R.string.on) );
|
|
||||||
aSwitch.setChecked(true);
|
|
||||||
handleChangeRequest(true);
|
|
||||||
} else {
|
|
||||||
aSwitch.setText(getString(R.string.action_white_list) +" "+getString(R.string.off) );
|
|
||||||
aSwitch.setChecked(false);
|
|
||||||
handleChangeRequest(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
|
||||||
toolbar.setTitle(getString(R.string.activity_title_whitelist));
|
|
||||||
setSupportActionBar(toolbar);
|
|
||||||
|
|
||||||
mAdapter = new WhiteListAdapter(this, whitelistedUsers);
|
|
||||||
recyclerView.setLayoutManager(new WrapContentLinearLayoutManager(getApplicationContext()));
|
|
||||||
recyclerView.setItemAnimator(new DefaultItemAnimator());
|
|
||||||
recyclerView.addItemDecoration(new MyDividerItemDecoration(this, LinearLayoutManager.VERTICAL, 16));
|
|
||||||
recyclerView.setAdapter(mAdapter);
|
|
||||||
noNotesView.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* On long press on RecyclerView item, open alert dialog
|
|
||||||
* with options to choose
|
|
||||||
* Edit and Delete
|
|
||||||
* */
|
|
||||||
recyclerView.addOnItemTouchListener(new RecyclerTouchListener(this,
|
|
||||||
recyclerView, new RecyclerTouchListener.ClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view, final int position) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onLongClick(View view, int position) {
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
addToWhiteListFab.setOnClickListener(this::showFabDialog);
|
|
||||||
fetchWhiteListedUsers();
|
|
||||||
handleSwitch();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Observable<List<String>> getListOfWhitelistedUsers(String userId) {
|
|
||||||
return userService.getTutorWhitelistedByID(userId)
|
|
||||||
.toObservable()
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.observeOn(AndroidSchedulers.mainThread());
|
|
||||||
}
|
|
||||||
|
|
||||||
private Observable<User> getUserObservable(String userId) {
|
|
||||||
return userService
|
|
||||||
.getUserById(userId)
|
|
||||||
.toObservable()
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.observeOn(AndroidSchedulers.mainThread());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void fetchWhiteListedUsers() {
|
|
||||||
disposable.add(getListOfWhitelistedUsers(tutorId)
|
|
||||||
.doOnSubscribe(this::handleDoOnSubscribe)
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.flatMap(Observable::fromIterable)
|
|
||||||
.flatMap(this::getUserObservable)
|
|
||||||
.subscribe(user -> whitelistedUsers.add(user), this::handleError,this::handleComplete));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleDoOnSubscribe(Disposable disposable) {
|
|
||||||
prevSize = whitelistedUsers.size();
|
|
||||||
whitelistedUsers.clear();
|
|
||||||
didFetched = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleComplete() {
|
|
||||||
Collections.sort(whitelistedUsers, this::sortByUserName);
|
|
||||||
didFetched = true;
|
|
||||||
refreshUI();
|
|
||||||
}
|
|
||||||
private void handleError(Throwable e){
|
|
||||||
showError(e);
|
|
||||||
didFetched = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void refreshUI() {
|
|
||||||
toggleEmptyNotes();
|
|
||||||
mAdapter.notifyItemRangeInserted(prevSize, whitelistedUsers.size() - prevSize);
|
|
||||||
mAdapter.notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
private int sortByUserName(User t1, User t2) {
|
|
||||||
return plCollator.compare(t1.getLastName(), t2.getLastName());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showFabDialog(View v) {
|
|
||||||
LayoutInflater layoutInflaterAndroid = LayoutInflater.from(getApplicationContext());
|
|
||||||
@SuppressLint("InflateParams") View view = layoutInflaterAndroid.inflate(R.layout.white_list_fab_modal, null);
|
|
||||||
AlertDialog.Builder alertDialogBuilderUserInput = new AlertDialog.Builder(this);
|
|
||||||
|
|
||||||
alertDialogBuilderUserInput.setView(view).setPositiveButton(getApplicationContext().getString(R.string.modal_location_send), null);
|
|
||||||
|
|
||||||
alertDialogBuilderUserInput
|
|
||||||
.setPositiveButton(R.string.add, null)
|
|
||||||
.setNegativeButton(R.string.cancel, null);
|
|
||||||
|
|
||||||
final AlertDialog alertDialog = alertDialogBuilderUserInput.create();
|
|
||||||
alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
|
|
||||||
|
|
||||||
EditText modalUserInput = view.findViewById(R.id.white_list_modal_input);
|
|
||||||
|
|
||||||
alertDialog.setOnShowListener(dialogInterface -> {
|
|
||||||
Button sendButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
|
|
||||||
|
|
||||||
Button dismissButton = alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE);
|
|
||||||
|
|
||||||
dismissButton.setOnClickListener(view1 -> alertDialog.dismiss());
|
|
||||||
|
|
||||||
sendButton.setOnClickListener(view1 -> {
|
|
||||||
String body = modalUserInput.getText().toString();
|
|
||||||
|
|
||||||
if (TextUtils.isEmpty(body)) {
|
|
||||||
Toast.makeText(getApplicationContext(), R.string.can_not_be_empty, Toast.LENGTH_SHORT).show();
|
|
||||||
modalUserInput.requestFocus();
|
|
||||||
} else {
|
|
||||||
sendUserToWhitelist(body);
|
|
||||||
alertDialog.dismiss();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
alertDialog.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sendUserToWhitelist(String body) {
|
|
||||||
StudentIdModel studentIdModel = new StudentIdModel(body);
|
|
||||||
|
|
||||||
disposable.add(
|
|
||||||
userService.addStudentToWhitelist(tutorId, studentIdModel)
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribe(this::handleAddUser, this::showError)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleAddUser(User user) {
|
|
||||||
Toast.makeText(this, R.string.add_user_to_list, Snackbar.LENGTH_LONG).show();
|
|
||||||
fetchWhiteListedUsers();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showError(Throwable e) {
|
|
||||||
String message;
|
|
||||||
|
|
||||||
if (e instanceof HttpException) {
|
|
||||||
ResponseBody responseBody = ((HttpException) e).response().errorBody();
|
|
||||||
message = RestApiHelper.getErrorMessage(responseBody);
|
|
||||||
if (((HttpException) e).response().code() == 404) {
|
|
||||||
message = getString(R.string.no_such_a_user);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
message = "Network Error !";
|
|
||||||
}
|
|
||||||
Log.e("ERR", message);
|
|
||||||
Toast.makeText(this, message, Snackbar.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void toggleEmptyNotes() {
|
|
||||||
|
|
||||||
if (didFetched && whitelistedUsers.size() == 0) {
|
|
||||||
noNotesView.setVisibility(View.VISIBLE);
|
|
||||||
noNotesView.setText(R.string.list_is_empty);
|
|
||||||
loader.setVisibility(View.GONE);
|
|
||||||
} else if (whitelistedUsers.size() > 0) {
|
|
||||||
noNotesView.setVisibility(View.GONE);
|
|
||||||
loader.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
loader.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
|
|
||||||
if (item.getItemId() == R.id.action_whitelist_info_popup) {
|
|
||||||
int layoutID = R.layout.info_popup_whitelist;
|
|
||||||
|
|
||||||
View popupView = getLayoutInflater().inflate(layoutID, null);
|
|
||||||
|
|
||||||
PopupWindow popupWindow = new PopupWindow(popupView,
|
|
||||||
LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
|
|
||||||
// If the PopupWindow should be focusable
|
|
||||||
popupWindow.setFocusable(true);
|
|
||||||
// If you need the PopupWindow to dismiss when when touched outside
|
|
||||||
popupWindow.setBackgroundDrawable(new ColorDrawable());
|
|
||||||
// Get the View's(the one that was clicked in the Fragment) location
|
|
||||||
View anchorView = getWindow().getDecorView().findViewById(android.R.id.content);
|
|
||||||
popupWindow.showAtLocation(anchorView, Gravity.TOP | Gravity.END, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.onOptionsItemSelected(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleSwitch() {
|
|
||||||
aSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
|
||||||
if (isChecked) {
|
|
||||||
aSwitch.setText(getString(R.string.action_white_list) + " " + getString(R.string.on));
|
|
||||||
handleChangeRequest(true);
|
|
||||||
PrefUtils.useWhitelist(this, true);
|
|
||||||
} else {
|
|
||||||
aSwitch.setText(getString(R.string.action_white_list) + " " + getString(R.string.off));
|
|
||||||
handleChangeRequest(false);
|
|
||||||
PrefUtils.useWhitelist(this, false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleChangeRequest(boolean value) {
|
|
||||||
IsUsingListBool isUsingListBool = new IsUsingListBool();
|
|
||||||
isUsingListBool.setIsUsing(value);
|
|
||||||
disposable.add(
|
|
||||||
userService.setTutorWhitelist(tutorId, isUsingListBool)
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribe(() -> {
|
|
||||||
}, this::showError)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPause() {
|
|
||||||
super.onPause();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStop() {
|
|
||||||
super.onStop();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDestroy() {
|
|
||||||
super.onDestroy();
|
|
||||||
disposable.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
|
||||||
getMenuInflater().inflate(R.menu.menu_white_list, menu);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,119 +0,0 @@
|
|||||||
package com.uam.wmi.findmytutor.adapters;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
import android.support.design.widget.Snackbar;
|
|
||||||
import android.support.v7.widget.RecyclerView;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.ImageButton;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
|
|
||||||
import com.uam.wmi.findmytutor.R;
|
|
||||||
import com.uam.wmi.findmytutor.model.StudentIdModel;
|
|
||||||
import com.uam.wmi.findmytutor.model.User;
|
|
||||||
import com.uam.wmi.findmytutor.network.ApiClient;
|
|
||||||
import com.uam.wmi.findmytutor.service.UserService;
|
|
||||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
|
||||||
import com.uam.wmi.findmytutor.utils.RestApiHelper;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
|
||||||
import io.reactivex.schedulers.Schedulers;
|
|
||||||
import okhttp3.ResponseBody;
|
|
||||||
|
|
||||||
import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext;
|
|
||||||
|
|
||||||
|
|
||||||
public class BlackListAdapter extends RecyclerView.Adapter<BlackListAdapter.MyViewHolder> {
|
|
||||||
|
|
||||||
private Context context;
|
|
||||||
private List<User> tutorsList;
|
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
|
||||||
private UserService userService;
|
|
||||||
|
|
||||||
public BlackListAdapter(Context context, List<User> tutors) {
|
|
||||||
this.context = context;
|
|
||||||
this.tutorsList = tutors;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
|
||||||
userService = ApiClient.getClient(getApplicationContext())
|
|
||||||
.create(UserService.class);
|
|
||||||
View itemView = LayoutInflater.from(parent.getContext())
|
|
||||||
.inflate(R.layout.black_list_row, parent, false);
|
|
||||||
|
|
||||||
return new MyViewHolder(itemView);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
|
|
||||||
Drawable image = null;
|
|
||||||
User tutor = tutorsList.get(position);
|
|
||||||
|
|
||||||
holder.firstName.setText(tutor.getFirstName() + " " + tutor.getLastName());
|
|
||||||
holder.lastName.setText("Index: " + tutor.getLdapLogin() + " Email: " + tutor.getEmail());
|
|
||||||
//"s416196"
|
|
||||||
holder.imageButton.setOnClickListener(l ->{
|
|
||||||
StudentIdModel studentIdModel = new StudentIdModel(tutor.getLdapLogin());
|
|
||||||
String tutorId = PrefUtils.getUserId(getApplicationContext());
|
|
||||||
disposable.add(
|
|
||||||
userService.removeStudentFromBlacklist(tutorId, studentIdModel)
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribe(()->{
|
|
||||||
Toast.makeText(getApplicationContext(), R.string.user_removed, Toast.LENGTH_SHORT).show();
|
|
||||||
tutorsList.remove(position);
|
|
||||||
notifyDataSetChanged();
|
|
||||||
},this::showError)
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getItemCount() {
|
|
||||||
return tutorsList.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
class MyViewHolder extends RecyclerView.ViewHolder {
|
|
||||||
|
|
||||||
@BindView(R.id.firstName)
|
|
||||||
TextView firstName;
|
|
||||||
|
|
||||||
@BindView(R.id.lastName)
|
|
||||||
TextView lastName;
|
|
||||||
|
|
||||||
@BindView(R.id.removeUserImageButton)
|
|
||||||
ImageButton imageButton;
|
|
||||||
|
|
||||||
MyViewHolder(View view) {
|
|
||||||
super(view);
|
|
||||||
ButterKnife.bind(this, view);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showError(Throwable e) {
|
|
||||||
String message;
|
|
||||||
|
|
||||||
if (e instanceof HttpException) {
|
|
||||||
ResponseBody responseBody = ((HttpException) e).response().errorBody();
|
|
||||||
message = RestApiHelper.getErrorMessage(responseBody);
|
|
||||||
} else {
|
|
||||||
message = "Network Error !";
|
|
||||||
}
|
|
||||||
|
|
||||||
Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,181 +0,0 @@
|
|||||||
package com.uam.wmi.findmytutor.adapters;
|
|
||||||
|
|
||||||
import android.app.DialogFragment;
|
|
||||||
import android.app.FragmentManager;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
import android.support.v7.widget.RecyclerView;
|
|
||||||
import android.text.Editable;
|
|
||||||
import android.text.TextWatcher;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.ImageButton;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import com.annimon.stream.Collectors;
|
|
||||||
import com.annimon.stream.Stream;
|
|
||||||
import com.uam.wmi.findmytutor.R;
|
|
||||||
import com.uam.wmi.findmytutor.activity.TimePickerFragment;
|
|
||||||
import com.uam.wmi.findmytutor.model.DutyHourViewModel;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
|
|
||||||
|
|
||||||
public class DutyHoursAdapter extends RecyclerView.Adapter<DutyHoursAdapter.MyViewHolder> {
|
|
||||||
private Context context;
|
|
||||||
private List<DutyHourViewModel> hours;
|
|
||||||
private FragmentManager fragmentManager;
|
|
||||||
|
|
||||||
public DutyHoursAdapter(Context context, List<DutyHourViewModel> hours, FragmentManager fragmentManager) {
|
|
||||||
this.context = context;
|
|
||||||
this.hours = new ArrayList<DutyHourViewModel>(hours);
|
|
||||||
this.fragmentManager = fragmentManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public List<DutyHourViewModel> getDutyList(){
|
|
||||||
ArrayList<DutyHourViewModel> notEmpty = Stream.of(hours).filter(DutyHourViewModel::isValid).collect(Collectors.toCollection(ArrayList::new));
|
|
||||||
return notEmpty;
|
|
||||||
}
|
|
||||||
public void addDuty(DutyHourViewModel duty){
|
|
||||||
hours.add(duty);
|
|
||||||
}
|
|
||||||
private void removeDuty(int pos){
|
|
||||||
hours.remove(pos);
|
|
||||||
this.notifyItemRemoved(pos);
|
|
||||||
Log.d("DutyIndex af rm size",Integer.toString(getItemCount()));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
|
||||||
View itemView = LayoutInflater.from(parent.getContext())
|
|
||||||
.inflate(R.layout.duty_hour_row, parent, false);
|
|
||||||
|
|
||||||
return new MyViewHolder(itemView);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
|
|
||||||
DutyHourViewModel duty = hours.get(position);
|
|
||||||
holder.dutyDay.setText(duty.getDay());
|
|
||||||
holder.dutyDay.addTextChangedListener(new TextWatcher() {
|
|
||||||
@Override
|
|
||||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void afterTextChanged(Editable s) {
|
|
||||||
duty.setDay(holder.dutyDay.getText().toString());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
holder.dutyStart.setText(duty.getStart());
|
|
||||||
/* holder.dutyStart.addTextChangedListener(new TextWatcher() {
|
|
||||||
@Override
|
|
||||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void afterTextChanged(Editable s) {
|
|
||||||
duty.setStart(holder.dutyStart.getText().toString());
|
|
||||||
}
|
|
||||||
});*/
|
|
||||||
holder.dutyStart.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
DialogFragment picker = new TimePickerFragment(holder.dutyStart,duty,"start");
|
|
||||||
picker.show(fragmentManager,"time picker");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
holder.dutyStop.setText(duty.getEnd());
|
|
||||||
holder.dutyStop.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
DialogFragment picker = new TimePickerFragment(holder.dutyStop,duty,"stop");
|
|
||||||
picker.show(fragmentManager,"time picker");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
/* holder.dutyStop.addTextChangedListener(new TextWatcher() {
|
|
||||||
@Override
|
|
||||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void afterTextChanged(Editable s) {
|
|
||||||
duty.setEnd(holder.dutyStop.getText().toString());
|
|
||||||
}
|
|
||||||
});*/
|
|
||||||
holder.deleteRow.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
try{
|
|
||||||
// Log.d("DutyIndex bf rm size",Integer.toString(getItemCount()));
|
|
||||||
// Log.d("DutyIndex bf rm pos",Integer.toString(holder.getLayoutPosition()));
|
|
||||||
removeDuty(holder.getLayoutPosition());
|
|
||||||
// Log.d("DutyIndex af rm pos",Integer.toString(holder.getLayoutPosition()));
|
|
||||||
|
|
||||||
|
|
||||||
}catch(Error e){
|
|
||||||
// Log.e("DutyIndex error",e.getMessage());
|
|
||||||
// Log.e("DutyIndex size",Integer.toString(getItemCount()));
|
|
||||||
// Log.e("DutyIndex pos",Integer.toString(holder.getAdapterPosition()));
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getItemCount() {
|
|
||||||
return hours.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
class MyViewHolder extends RecyclerView.ViewHolder {
|
|
||||||
|
|
||||||
@BindView(R.id.duty_day_value)
|
|
||||||
TextView dutyDay;
|
|
||||||
|
|
||||||
@BindView(R.id.duty_start_value)
|
|
||||||
TextView dutyStart;
|
|
||||||
|
|
||||||
@BindView(R.id.duty_stop_value)
|
|
||||||
TextView dutyStop;
|
|
||||||
|
|
||||||
@BindView(R.id.deleteRow)
|
|
||||||
ImageButton deleteRow;
|
|
||||||
|
|
||||||
MyViewHolder(View view) {
|
|
||||||
super(view);
|
|
||||||
ButterKnife.bind(this, view);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,4 +1,3 @@
|
|||||||
/*
|
|
||||||
package com.uam.wmi.findmytutor.adapters;
|
package com.uam.wmi.findmytutor.adapters;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -10,11 +9,9 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.github.ybq.android.spinkit.SpinKitView;
|
|
||||||
import com.uam.wmi.findmytutor.R;
|
import com.uam.wmi.findmytutor.R;
|
||||||
import com.uam.wmi.findmytutor.model.User;
|
import com.uam.wmi.findmytutor.model.User;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
@ -25,123 +22,10 @@ public class TutorsListAdapter extends RecyclerView.Adapter<TutorsListAdapter.My
|
|||||||
|
|
||||||
private Context context;
|
private Context context;
|
||||||
private List<User> tutorsList;
|
private List<User> tutorsList;
|
||||||
private HashMap<String, String> tutorsTimeStamps;
|
|
||||||
|
|
||||||
public TutorsListAdapter(Context context, List<User> tutors, HashMap<String,String> tutorsTimeStamps) {
|
public TutorsListAdapter(Context context, List<User> tutors) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.tutorsList = tutors;
|
this.tutorsList = tutors;
|
||||||
this.tutorsTimeStamps = tutorsTimeStamps;
|
|
||||||
}
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
|
||||||
View itemView = LayoutInflater.from(parent.getContext())
|
|
||||||
.inflate(R.layout.tutor_list_row, parent, false);
|
|
||||||
|
|
||||||
return new MyViewHolder(itemView);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
|
|
||||||
Drawable image = null;
|
|
||||||
User tutor = tutorsList.get(position);
|
|
||||||
|
|
||||||
holder.firstName.setText(String.format("%s %s", tutor.getFirstName(), tutor.getLastName()));
|
|
||||||
String ts = tutorsTimeStamps.get(tutor.getId());
|
|
||||||
|
|
||||||
if (tutor.isIsOnline()) {
|
|
||||||
image = context.getResources().getDrawable(R.drawable.user_list_online);
|
|
||||||
holder.lastSeen.setText(R.string.available_now);
|
|
||||||
holder.loader.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
image = context.getResources().getDrawable(R.drawable.user_list_offline);
|
|
||||||
|
|
||||||
if (ts != null){
|
|
||||||
holder.lastSeen.setText(R.string.last_sign);
|
|
||||||
holder.lastSeen.append(String.format(": %s", ts));
|
|
||||||
holder.loader.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!tutor.isIsActive()) {
|
|
||||||
image = context.getResources().getDrawable(R.drawable.user_list_off);
|
|
||||||
if(ts != null){
|
|
||||||
holder.lastSeen.setText(R.string.last_sign);
|
|
||||||
holder.lastSeen.append(String.format(": %s", ts));
|
|
||||||
}else{
|
|
||||||
holder.lastSeen.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
holder.loader.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
image.setBounds(0, 0, image.getIntrinsicWidth(), image.getIntrinsicHeight());
|
|
||||||
holder.isOnline.setCompoundDrawables(image, null, null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getItemCount() {
|
|
||||||
return tutorsList.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
class MyViewHolder extends RecyclerView.ViewHolder {
|
|
||||||
|
|
||||||
@BindView(R.id.firstName)
|
|
||||||
TextView firstName;
|
|
||||||
|
|
||||||
@BindView(R.id.lastSeen)
|
|
||||||
TextView lastSeen;
|
|
||||||
|
|
||||||
@BindView(R.id.isOnline)
|
|
||||||
TextView isOnline;
|
|
||||||
|
|
||||||
@BindView(R.id.loader)
|
|
||||||
SpinKitView loader;
|
|
||||||
|
|
||||||
MyViewHolder(View view) {
|
|
||||||
super(view);
|
|
||||||
ButterKnife.bind(this, view);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
package com.uam.wmi.findmytutor.adapters;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
import android.support.v7.widget.RecyclerView;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.github.ybq.android.spinkit.SpinKitView;
|
|
||||||
import com.uam.wmi.findmytutor.R;
|
|
||||||
import com.uam.wmi.findmytutor.model.User;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
|
|
||||||
|
|
||||||
public class TutorsListAdapter extends RecyclerView.Adapter<TutorsListAdapter.MyViewHolder> {
|
|
||||||
|
|
||||||
private Context context;
|
|
||||||
private List<User> tutorsList;
|
|
||||||
private HashMap<String, String> tutorsTimeStamps;
|
|
||||||
|
|
||||||
public TutorsListAdapter(Context context, List<User> tutors, HashMap<String,String> tutorsTimeStamps) {
|
|
||||||
this.context = context;
|
|
||||||
this.tutorsList = tutors;
|
|
||||||
this.tutorsTimeStamps = tutorsTimeStamps;
|
|
||||||
}
|
}
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
@ -157,32 +41,17 @@ public class TutorsListAdapter extends RecyclerView.Adapter<TutorsListAdapter.My
|
|||||||
Drawable image = null;
|
Drawable image = null;
|
||||||
User tutor = tutorsList.get(position);
|
User tutor = tutorsList.get(position);
|
||||||
|
|
||||||
holder.firstName.setText(String.format("%s %s", tutor.getFirstName(), tutor.getLastName()));
|
holder.firstName.setText(tutor.getFirstName());
|
||||||
String ts = tutorsTimeStamps.get(tutor.getId());
|
holder.lastName.setText(tutor.getLastName());
|
||||||
|
|
||||||
if (tutor.isIsOnline()) {
|
if (tutor.isIsOnline()) {
|
||||||
image = context.getResources().getDrawable(R.drawable.user_list_online);
|
image = context.getResources().getDrawable(R.drawable.user_list_online);
|
||||||
holder.lastSeen.setText(R.string.available_now);
|
|
||||||
holder.lastSeen.setVisibility(View.VISIBLE);
|
|
||||||
holder.loader.setVisibility(View.GONE);
|
|
||||||
} else if(tutor.isIsActive()){
|
|
||||||
image = context.getResources().getDrawable(R.drawable.user_list_offline);
|
|
||||||
|
|
||||||
if (ts != null){
|
|
||||||
holder.lastSeen.setText(R.string.last_sign);
|
|
||||||
holder.lastSeen.append(String.format(": %s", ts));
|
|
||||||
holder.loader.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
image = context.getResources().getDrawable(R.drawable.user_list_off);
|
image = context.getResources().getDrawable(R.drawable.user_list_offline);
|
||||||
|
}
|
||||||
|
|
||||||
if(ts == null){
|
if (!tutor.isIsActive()) {
|
||||||
holder.lastSeen.setText(R.string.never_logged_in);
|
image = context.getResources().getDrawable(R.drawable.user_list_off);
|
||||||
}else{
|
|
||||||
holder.lastSeen.setText(R.string.last_sign);
|
|
||||||
holder.lastSeen.append(String.format(": %s", ts));
|
|
||||||
}
|
|
||||||
holder.loader.setVisibility(View.GONE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
image.setBounds(0, 0, image.getIntrinsicWidth(), image.getIntrinsicHeight());
|
image.setBounds(0, 0, image.getIntrinsicWidth(), image.getIntrinsicHeight());
|
||||||
@ -199,21 +68,17 @@ public class TutorsListAdapter extends RecyclerView.Adapter<TutorsListAdapter.My
|
|||||||
@BindView(R.id.firstName)
|
@BindView(R.id.firstName)
|
||||||
TextView firstName;
|
TextView firstName;
|
||||||
|
|
||||||
@BindView(R.id.lastSeen)
|
@BindView(R.id.lastName)
|
||||||
TextView lastSeen;
|
TextView lastName;
|
||||||
|
|
||||||
@BindView(R.id.isOnline)
|
@BindView(R.id.isOnline)
|
||||||
TextView isOnline;
|
TextView isOnline;
|
||||||
|
|
||||||
@BindView(R.id.loader)
|
|
||||||
SpinKitView loader;
|
|
||||||
|
|
||||||
MyViewHolder(View view) {
|
MyViewHolder(View view) {
|
||||||
super(view);
|
super(view);
|
||||||
ButterKnife.bind(this, view);
|
ButterKnife.bind(this, view);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -1,117 +0,0 @@
|
|||||||
package com.uam.wmi.findmytutor.adapters;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
import android.support.v7.widget.RecyclerView;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.ImageButton;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
|
|
||||||
import com.uam.wmi.findmytutor.R;
|
|
||||||
import com.uam.wmi.findmytutor.model.StudentIdModel;
|
|
||||||
import com.uam.wmi.findmytutor.model.User;
|
|
||||||
import com.uam.wmi.findmytutor.network.ApiClient;
|
|
||||||
import com.uam.wmi.findmytutor.service.UserService;
|
|
||||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
|
||||||
import com.uam.wmi.findmytutor.utils.RestApiHelper;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
|
||||||
import io.reactivex.schedulers.Schedulers;
|
|
||||||
import okhttp3.ResponseBody;
|
|
||||||
|
|
||||||
import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext;
|
|
||||||
|
|
||||||
|
|
||||||
public class WhiteListAdapter extends RecyclerView.Adapter<WhiteListAdapter.MyViewHolder> {
|
|
||||||
|
|
||||||
private Context context;
|
|
||||||
private List<User> tutorsList;
|
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
|
||||||
private UserService userService;
|
|
||||||
|
|
||||||
public WhiteListAdapter(Context context, List<User> tutors) {
|
|
||||||
this.context = context;
|
|
||||||
this.tutorsList = tutors;
|
|
||||||
}
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
|
||||||
userService = ApiClient.getClient(getApplicationContext())
|
|
||||||
.create(UserService.class);
|
|
||||||
View itemView = LayoutInflater.from(parent.getContext())
|
|
||||||
.inflate(R.layout.white_list_row, parent, false);
|
|
||||||
|
|
||||||
return new MyViewHolder(itemView);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
|
|
||||||
Drawable image = null;
|
|
||||||
User tutor = tutorsList.get(position);
|
|
||||||
|
|
||||||
holder.firstName.setText(tutor.getFirstName() + " " + tutor.getLastName());
|
|
||||||
holder.lastName.setText("Index: " + tutor.getLdapLogin() + " Email: " + tutor.getEmail());
|
|
||||||
//""
|
|
||||||
holder.imageButton.setOnClickListener(l ->{
|
|
||||||
StudentIdModel studentIdModel = new StudentIdModel(tutor.getLdapLogin());
|
|
||||||
String tutorId = PrefUtils.getUserId(getApplicationContext());
|
|
||||||
disposable.add(
|
|
||||||
userService.removeStudentFromWhitelist(tutorId, studentIdModel)
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribe(()->{
|
|
||||||
Toast.makeText(getApplicationContext(), R.string.user_removed, Toast.LENGTH_SHORT).show();
|
|
||||||
tutorsList.remove(position);
|
|
||||||
notifyDataSetChanged();
|
|
||||||
},this::showError)
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getItemCount() {
|
|
||||||
return tutorsList.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
class MyViewHolder extends RecyclerView.ViewHolder {
|
|
||||||
|
|
||||||
@BindView(R.id.firstName)
|
|
||||||
TextView firstName;
|
|
||||||
|
|
||||||
@BindView(R.id.lastName)
|
|
||||||
TextView lastName;
|
|
||||||
|
|
||||||
@BindView(R.id.removeUserImageButton)
|
|
||||||
ImageButton imageButton;
|
|
||||||
|
|
||||||
MyViewHolder(View view) {
|
|
||||||
super(view);
|
|
||||||
ButterKnife.bind(this, view);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showError(Throwable e) {
|
|
||||||
String message;
|
|
||||||
|
|
||||||
if (e instanceof HttpException) {
|
|
||||||
ResponseBody responseBody = ((HttpException) e).response().errorBody();
|
|
||||||
message = RestApiHelper.getErrorMessage(responseBody);
|
|
||||||
} else {
|
|
||||||
message = "Network Error !";
|
|
||||||
}
|
|
||||||
Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -20,6 +20,9 @@ public class Coordinate extends BaseResponse {
|
|||||||
private Range<Double> longtitudeRange = Const.buildingLongitudeRange;
|
private Range<Double> longtitudeRange = Const.buildingLongitudeRange;
|
||||||
private List<String> allowedApproximatedLocations = Const.validApproximatedLocations;
|
private List<String> allowedApproximatedLocations = Const.validApproximatedLocations;
|
||||||
|
|
||||||
|
@SerializedName("coordinateId")
|
||||||
|
private UUID coordinateId = null;
|
||||||
|
|
||||||
@SerializedName("latitude")
|
@SerializedName("latitude")
|
||||||
private Double latitude;
|
private Double latitude;
|
||||||
|
|
||||||
@ -63,9 +66,23 @@ public class Coordinate extends BaseResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Coordinate coordinateId(UUID coordinateId) {
|
public Coordinate coordinateId(UUID coordinateId) {
|
||||||
|
this.coordinateId = coordinateId;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get coordinateId
|
||||||
|
* @return coordinateId
|
||||||
|
**/
|
||||||
|
@ApiModelProperty(required = true, value = "")
|
||||||
|
public UUID getCoordinateId() {
|
||||||
|
return coordinateId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCoordinateId(UUID coordinateId) {
|
||||||
|
this.coordinateId = coordinateId;
|
||||||
|
}
|
||||||
|
|
||||||
public Coordinate latitude(Double latitude) {
|
public Coordinate latitude(Double latitude) {
|
||||||
this.latitude = latitude;
|
this.latitude = latitude;
|
||||||
return this;
|
return this;
|
||||||
@ -219,7 +236,8 @@ public class Coordinate extends BaseResponse {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Coordinate coordinate = (Coordinate) o;
|
Coordinate coordinate = (Coordinate) o;
|
||||||
return Objects.equals(this.latitude, coordinate.latitude) &&
|
return Objects.equals(this.coordinateId, coordinate.coordinateId) &&
|
||||||
|
Objects.equals(this.latitude, coordinate.latitude) &&
|
||||||
Objects.equals(this.longitude, coordinate.longitude) &&
|
Objects.equals(this.longitude, coordinate.longitude) &&
|
||||||
Objects.equals(this.altitude, coordinate.altitude) &&
|
Objects.equals(this.altitude, coordinate.altitude) &&
|
||||||
Objects.equals(this.userId, coordinate.userId) &&
|
Objects.equals(this.userId, coordinate.userId) &&
|
||||||
@ -231,7 +249,7 @@ public class Coordinate extends BaseResponse {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash( latitude, longitude, altitude, userId, approximatedLocation, displayMode, timeStamp, label);
|
return Objects.hash(coordinateId, latitude, longitude, altitude, userId, approximatedLocation, displayMode, timeStamp, label);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -240,6 +258,7 @@ public class Coordinate extends BaseResponse {
|
|||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("class Coordinate {\n");
|
sb.append("class Coordinate {\n");
|
||||||
|
|
||||||
|
sb.append(" coordinateId: ").append(toIndentedString(coordinateId)).append("\n");
|
||||||
sb.append(" latitude: ").append(toIndentedString(latitude)).append("\n");
|
sb.append(" latitude: ").append(toIndentedString(latitude)).append("\n");
|
||||||
sb.append(" longitude: ").append(toIndentedString(longitude)).append("\n");
|
sb.append(" longitude: ").append(toIndentedString(longitude)).append("\n");
|
||||||
sb.append(" altitude: ").append(toIndentedString(altitude)).append("\n");
|
sb.append(" altitude: ").append(toIndentedString(altitude)).append("\n");
|
||||||
|
@ -24,20 +24,6 @@ public class DutyHourViewModel {
|
|||||||
this.day = day;
|
this.day = day;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public Boolean isValid(){
|
|
||||||
if(this.day.isEmpty()){
|
|
||||||
return false;
|
|
||||||
}else if( !this.start.isEmpty() && this.end.isEmpty() ){
|
|
||||||
return false;
|
|
||||||
}else{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public DutyHourViewModel(){
|
|
||||||
day="";
|
|
||||||
start="";
|
|
||||||
end="";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get day
|
* Get day
|
||||||
@ -108,11 +94,12 @@ public class DutyHourViewModel {
|
|||||||
return Objects.hash(day, start, end);
|
return Objects.hash(day, start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getSummary() {
|
public String getSummary() {
|
||||||
return this.getDay() + ": " + this.getStart() + " - " + this.getEnd();
|
return this.getDay() + " " + this.getStart() + " " + this.getEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
@ -18,15 +18,6 @@ public class StudentIdModel extends BaseResponse{
|
|||||||
@SerializedName("ldapLogin")
|
@SerializedName("ldapLogin")
|
||||||
private String ldapLogin = null;
|
private String ldapLogin = null;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param str
|
|
||||||
*/
|
|
||||||
public StudentIdModel(String str){
|
|
||||||
// this.studentId = str;
|
|
||||||
this.ldapLogin = str;
|
|
||||||
}
|
|
||||||
|
|
||||||
public StudentIdModel studentId(String studentId) {
|
public StudentIdModel studentId(String studentId) {
|
||||||
this.studentId = studentId;
|
this.studentId = studentId;
|
||||||
return this;
|
return this;
|
||||||
|
@ -33,12 +33,11 @@ public class TutorTabViewModel {
|
|||||||
@SerializedName("dutyHours")
|
@SerializedName("dutyHours")
|
||||||
private List<DutyHourViewModel> dutyHours = null;
|
private List<DutyHourViewModel> dutyHours = null;
|
||||||
|
|
||||||
public TutorTabViewModel(String userId, String room, String email, String note, List<DutyHourViewModel> dutyHours){
|
public TutorTabViewModel(String userId, String note){
|
||||||
this.userId=userId;
|
this.userId=userId;
|
||||||
this.room=room;
|
// this.room=room;
|
||||||
this.emailTutorTab=email;
|
// this.emailTutorTab=emailTutorTab;
|
||||||
this.note=note;
|
this.note=note;
|
||||||
this.dutyHours = new ArrayList<DutyHourViewModel>(dutyHours);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TutorTabViewModel tutorTabId(UUID tutorTabId) {
|
public TutorTabViewModel tutorTabId(UUID tutorTabId) {
|
||||||
|
@ -4,7 +4,6 @@ import android.content.Context;
|
|||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import com.jakewharton.retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
|
import com.jakewharton.retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
|
||||||
import com.uam.wmi.findmytutor.utils.Const;
|
|
||||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -27,6 +26,7 @@ public class ApiClient {
|
|||||||
private static Retrofit retrofit = null;
|
private static Retrofit retrofit = null;
|
||||||
private static int REQUEST_TIMEOUT = 60;
|
private static int REQUEST_TIMEOUT = 60;
|
||||||
private static OkHttpClient okHttpClient;
|
private static OkHttpClient okHttpClient;
|
||||||
|
private static final String BASE_URL = "https://s416084.projektstudencki.pl/master/";
|
||||||
|
|
||||||
public static Retrofit getClient(Context context) {
|
public static Retrofit getClient(Context context) {
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ public class ApiClient {
|
|||||||
|
|
||||||
if (retrofit == null) {
|
if (retrofit == null) {
|
||||||
retrofit = new Retrofit.Builder()
|
retrofit = new Retrofit.Builder()
|
||||||
.baseUrl(Const.BASE_URL)
|
.baseUrl(BASE_URL)
|
||||||
.client(okHttpClient)
|
.client(okHttpClient)
|
||||||
.addConverterFactory(GsonConverterFactory.create())
|
.addConverterFactory(GsonConverterFactory.create())
|
||||||
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
|
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
|
||||||
|
@ -11,13 +11,12 @@ import android.content.Intent;
|
|||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
import android.location.LocationListener;
|
|
||||||
import android.location.LocationManager;
|
import android.location.LocationManager;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.Looper;
|
|
||||||
import android.support.annotation.RequiresApi;
|
import android.support.annotation.RequiresApi;
|
||||||
import android.support.v4.app.ActivityCompat;
|
import android.support.v4.app.ActivityCompat;
|
||||||
import android.support.v4.app.NotificationCompat;
|
import android.support.v4.app.NotificationCompat;
|
||||||
@ -25,29 +24,25 @@ import android.util.Log;
|
|||||||
|
|
||||||
import com.annimon.stream.Stream;
|
import com.annimon.stream.Stream;
|
||||||
import com.google.android.gms.location.FusedLocationProviderClient;
|
import com.google.android.gms.location.FusedLocationProviderClient;
|
||||||
import com.google.android.gms.location.LocationCallback;
|
|
||||||
import com.google.android.gms.location.LocationRequest;
|
|
||||||
import com.google.android.gms.location.LocationResult;
|
|
||||||
import com.google.android.gms.location.LocationServices;
|
import com.google.android.gms.location.LocationServices;
|
||||||
import com.mapbox.geojson.Point;
|
import com.mapbox.geojson.Point;
|
||||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||||
import com.uam.wmi.findmytutor.model.Coordinate;
|
import com.uam.wmi.findmytutor.model.Coordinate;
|
||||||
import com.uam.wmi.findmytutor.network.ApiClient;
|
import com.uam.wmi.findmytutor.network.ApiClient;
|
||||||
import com.uam.wmi.findmytutor.utils.ApproximatedLocalization;
|
import com.uam.wmi.findmytutor.utils.ApproximatedLocalization;
|
||||||
import com.uam.wmi.findmytutor.utils.Const;
|
|
||||||
import com.uam.wmi.findmytutor.utils.MapUtils;
|
import com.uam.wmi.findmytutor.utils.MapUtils;
|
||||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||||
import com.uam.wmi.findmytutor.utils.SharingLevel;
|
import com.uam.wmi.findmytutor.utils.SharingLevel;
|
||||||
import com.uam.wmi.findmytutor.utils.WifiUtils;
|
|
||||||
|
|
||||||
import org.apache.commons.collections4.queue.CircularFifoQueue;
|
import org.apache.commons.collections4.queue.CircularFifoQueue;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
import io.reactivex.observers.DisposableCompletableObserver;
|
import io.reactivex.observers.DisposableSingleObserver;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
import io.reactivex.schedulers.Schedulers;
|
||||||
|
|
||||||
import static com.uam.wmi.findmytutor.utils.Const.offlineBackgroundLocationInterval;
|
import static com.uam.wmi.findmytutor.utils.Const.offlineBackgroundLocationInterval;
|
||||||
@ -56,38 +51,36 @@ import static com.uam.wmi.findmytutor.utils.Const.presenceApproximatedName;
|
|||||||
import static com.uam.wmi.findmytutor.utils.Const.presenceLatitude;
|
import static com.uam.wmi.findmytutor.utils.Const.presenceLatitude;
|
||||||
import static com.uam.wmi.findmytutor.utils.Const.presenceLongitude;
|
import static com.uam.wmi.findmytutor.utils.Const.presenceLongitude;
|
||||||
import static com.uam.wmi.findmytutor.utils.PrefUtils.storeBackgroundLocationStatus;
|
import static com.uam.wmi.findmytutor.utils.PrefUtils.storeBackgroundLocationStatus;
|
||||||
import static java.lang.String.valueOf;
|
|
||||||
|
|
||||||
public class BackgroundLocalizationService extends Service {
|
public class BackgroundLocalizationService extends Service {
|
||||||
|
|
||||||
private static final String TAG = "MyLocationService";
|
private static final String TAG = "MyLocationService";
|
||||||
private static Integer notify_interval = onlineBackgroundLocationInterval;
|
private static final float LOCATION_DISTANCE = 1f;
|
||||||
private static Integer notify_interval_inside_building = onlineBackgroundLocationInterval;
|
private static long notify_interval = onlineBackgroundLocationInterval;
|
||||||
private static Integer notify_interval_outside_building = offlineBackgroundLocationInterval;
|
private static long notify_interval_inside_building = onlineBackgroundLocationInterval;
|
||||||
private static int coordinatesHistoryLength = 10;
|
private static long notify_interval_outside_building = offlineBackgroundLocationInterval;
|
||||||
private Boolean highAccuracyMode;
|
private static int coordinatesHistoryLength = 5;
|
||||||
|
private static final Long LOCATION_INTERVAL = notify_interval;
|
||||||
private Location mLastLocation;
|
private Location mLastLocation;
|
||||||
private Boolean stopService = false;
|
private Boolean stopService = false;
|
||||||
private ArrayList<String> providers = new ArrayList<String>();
|
private ArrayList<String> providers = new ArrayList<String>();
|
||||||
|
private LocationListener[] mLocationListeners;
|
||||||
private CircularFifoQueue<Location> coordinatesHistory = new CircularFifoQueue<Location>(coordinatesHistoryLength);
|
private CircularFifoQueue<Location> coordinatesHistory = new CircularFifoQueue<Location>(coordinatesHistoryLength);
|
||||||
|
private LocationManager mLocationManager = null;
|
||||||
private Handler mHandler = new Handler();
|
private Handler mHandler = new Handler();
|
||||||
private Runnable mStatusChecker;
|
private Runnable mStatusChecker;
|
||||||
private FusedLocationProviderClient mFusedLocationClient;
|
private FusedLocationProviderClient mFusedLocationClient;
|
||||||
private Location fakeLoc = null;
|
|
||||||
private LocationRequest mLocationRequest;
|
|
||||||
private Location mCurrentLocation;
|
|
||||||
private LocationCallback mLocationCallback;
|
|
||||||
private LocationListener mLocationListener;
|
|
||||||
|
|
||||||
public BackgroundLocalizationService() {
|
public BackgroundLocalizationService() {
|
||||||
providers.add(LocationManager.GPS_PROVIDER);
|
providers.add(LocationManager.GPS_PROVIDER);
|
||||||
providers.add(LocationManager.NETWORK_PROVIDER);
|
providers.add(LocationManager.NETWORK_PROVIDER);
|
||||||
providers.add(LocationManager.PASSIVE_PROVIDER);
|
providers.add(LocationManager.PASSIVE_PROVIDER);
|
||||||
fakeLoc = new Location("");
|
|
||||||
|
|
||||||
fakeLoc.setLatitude(0);
|
mLocationListeners = new LocationListener[]{
|
||||||
fakeLoc.setLongitude(0);
|
new LocationListener(LocationManager.GPS_PROVIDER),
|
||||||
fakeLoc.setAltitude(0);
|
new LocationListener(LocationManager.NETWORK_PROVIDER),
|
||||||
|
new LocationListener(LocationManager.PASSIVE_PROVIDER)
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -102,9 +95,7 @@ public class BackgroundLocalizationService extends Service {
|
|||||||
|
|
||||||
if (intent != null) {
|
if (intent != null) {
|
||||||
stopService = intent.getBooleanExtra("request_stop", false);
|
stopService = intent.getBooleanExtra("request_stop", false);
|
||||||
notify_interval = intent.getIntExtra("notify_interval", onlineBackgroundLocationInterval);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stopService) {
|
if (stopService) {
|
||||||
storeBackgroundLocationStatus(getApplication(), false);
|
storeBackgroundLocationStatus(getApplication(), false);
|
||||||
stopForeground(true);
|
stopForeground(true);
|
||||||
@ -115,26 +106,6 @@ public class BackgroundLocalizationService extends Service {
|
|||||||
return START_STICKY;
|
return START_STICKY;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createLocationCallback() {
|
|
||||||
mLocationCallback = new LocationCallback() {
|
|
||||||
@Override
|
|
||||||
public void onLocationResult(LocationResult locationResult) {
|
|
||||||
super.onLocationResult(locationResult);
|
|
||||||
if (locationResult != null) {
|
|
||||||
mCurrentLocation = locationResult.getLastLocation();
|
|
||||||
sendCoordinateToBackend(mCurrentLocation);
|
|
||||||
changeBackgroundMode();
|
|
||||||
|
|
||||||
//Restart service when a user started using presence in GPS mode and wmi is currently available
|
|
||||||
if (WifiUtils.checkIfUserIsInRangeOfWmiWifi(getApplicationContext())
|
|
||||||
&& PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.PRESENCE.toString())) {
|
|
||||||
restartService();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
Log.e(TAG, "onCreate");
|
Log.e(TAG, "onCreate");
|
||||||
@ -148,107 +119,57 @@ public class BackgroundLocalizationService extends Service {
|
|||||||
startForeground(1001, notification);
|
startForeground(1001, notification);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!stopService) {
|
mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this);
|
||||||
if (PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.PRESENCE.toString())) {
|
|
||||||
if (WifiUtils.checkIfUserIsInRangeOfWmiWifi(getApplicationContext())) {
|
|
||||||
Location presenceFakeLoc = new Location("");
|
|
||||||
|
|
||||||
presenceFakeLoc.setLatitude(Const.presenceLatitude);
|
initializeLocationManager();
|
||||||
presenceFakeLoc.setLongitude(Const.presenceLongitude);
|
|
||||||
presenceFakeLoc.setAltitude(0);
|
|
||||||
createPresenceLooper(presenceFakeLoc);
|
|
||||||
} else {
|
|
||||||
createFusedLocationClient();
|
|
||||||
}
|
|
||||||
} else if (PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.EXACT.toString())
|
|
||||||
|| PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.APPROXIMATED.toString())
|
|
||||||
) {
|
|
||||||
createFusedLocationClient();
|
|
||||||
} else if (PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.MANUAL.toString())) {
|
|
||||||
Location manualFakeLoc = new Location("");
|
|
||||||
|
|
||||||
manualFakeLoc.setLatitude(0);
|
Integer providerIndex = 0;
|
||||||
manualFakeLoc.setLongitude(0);
|
|
||||||
manualFakeLoc.setAltitude(0);
|
|
||||||
createLowBatteryLooper(manualFakeLoc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createLowBatteryLooper(Location fakeLoc) {
|
for (LocationListener listener : mLocationListeners) {
|
||||||
mStatusChecker = () -> {
|
|
||||||
try {
|
try {
|
||||||
sendCoordinateToBackend(fakeLoc);
|
mLocationManager.requestLocationUpdates(
|
||||||
} finally {
|
providers.get(providerIndex),
|
||||||
mHandler.postDelayed(mStatusChecker, notify_interval);
|
LOCATION_INTERVAL,
|
||||||
|
LOCATION_DISTANCE,
|
||||||
|
listener
|
||||||
|
);
|
||||||
|
|
||||||
|
} catch (java.lang.SecurityException ex) {
|
||||||
|
Log.i(TAG, "fail to request location update, ignore", ex);
|
||||||
|
} catch (IllegalArgumentException ex) {
|
||||||
|
Log.d(TAG, "network provider does not exist, " + ex.getMessage());
|
||||||
}
|
}
|
||||||
};
|
|
||||||
AsyncTask.execute(mStatusChecker);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createPresenceLooper(Location fakeLoc) {
|
providerIndex++;
|
||||||
mStatusChecker = () -> {
|
|
||||||
try {
|
|
||||||
if (WifiUtils.checkIfUserIsInRangeOfWmiWifi(getApplicationContext())) {
|
|
||||||
sendCoordinateToBackend(fakeLoc);
|
|
||||||
} else {
|
|
||||||
restartService();
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
mHandler.postDelayed(mStatusChecker, notify_interval);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
AsyncTask.execute(mStatusChecker);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void createFusedLocationClient() {
|
|
||||||
Integer saveMode = Long.valueOf(notify_interval).compareTo(Long.valueOf(offlineBackgroundLocationInterval));
|
|
||||||
|
|
||||||
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mLocationRequest = new LocationRequest();
|
|
||||||
|
|
||||||
if (saveMode != 0) {
|
|
||||||
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
|
|
||||||
} else {
|
|
||||||
mLocationRequest.setPriority(LocationRequest.PRIORITY_LOW_POWER);
|
|
||||||
}
|
|
||||||
|
|
||||||
mLocationRequest.setFastestInterval(notify_interval);
|
|
||||||
mLocationRequest.setInterval(notify_interval);
|
|
||||||
|
|
||||||
createLocationCallback();
|
|
||||||
|
|
||||||
if (!stopService) {
|
if (!stopService) {
|
||||||
mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this);
|
mStatusChecker = () -> {
|
||||||
mFusedLocationClient.requestLocationUpdates(mLocationRequest,
|
try {
|
||||||
mLocationCallback, Looper.getMainLooper());
|
getLocalizationFromListeners();
|
||||||
|
changeBackgroundMode();
|
||||||
|
} finally {
|
||||||
|
mHandler.postDelayed(mStatusChecker, notify_interval);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
AsyncTask.execute(mStatusChecker);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void changeBackgroundMode() {
|
private void changeBackgroundMode() {
|
||||||
Integer prevInterval = notify_interval;
|
if (coordinatesHistory.size() > 4) {
|
||||||
Boolean shouldExtendTimeInterval = Stream.of(coordinatesHistory)
|
Boolean shouldExtendTimeInterval = Stream.of(coordinatesHistory)
|
||||||
.map(MapUtils::checkIfCoordinateIsValid).takeWhile(s -> !s).toList().size() == coordinatesHistoryLength;
|
.map(MapUtils::checkIfCoordinateIsValid).takeWhile(s -> !s).toList().size() == coordinatesHistory.size();
|
||||||
|
|
||||||
Boolean shouldAbbreviateTimeInterval = Stream.of(coordinatesHistory).
|
Boolean shouldAbbreviateTimeInterval = Stream.of(coordinatesHistory).
|
||||||
map(MapUtils::checkIfCoordinateIsValid).filter(x -> x).toList().size() > 0;
|
map(MapUtils::checkIfCoordinateIsValid).toList().get(coordinatesHistory.size() - 1);
|
||||||
|
|
||||||
if (shouldExtendTimeInterval) {
|
if (shouldExtendTimeInterval) {
|
||||||
notify_interval = notify_interval_outside_building;
|
notify_interval = notify_interval_outside_building;
|
||||||
}
|
} else if (shouldAbbreviateTimeInterval) {
|
||||||
|
notify_interval = notify_interval_inside_building;
|
||||||
if (shouldAbbreviateTimeInterval) {
|
}
|
||||||
notify_interval = notify_interval_inside_building;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Integer changedMode = Long.valueOf(prevInterval).compareTo(Long.valueOf(notify_interval));
|
|
||||||
if (changedMode != 0) {
|
|
||||||
updateListeners();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,6 +193,50 @@ public class BackgroundLocalizationService extends Service {
|
|||||||
startForeground(2, notification);
|
startForeground(2, notification);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void getLocalizationFromListeners() {
|
||||||
|
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||||
|
// TODO: Consider calling
|
||||||
|
// ActivityCompat#requestPermissions
|
||||||
|
// here to request the missing permissions, and then overriding
|
||||||
|
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
|
||||||
|
// int[] grantResults)
|
||||||
|
// to handle the case where the user grants the permission. See the documentation
|
||||||
|
// for ActivityCompat#requestPermissions for more details.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> providers1 = mLocationManager.getProviders(true);
|
||||||
|
Location bestLocation = null;
|
||||||
|
AtomicReference<Boolean> triggerAnotherLocationListener = new AtomicReference<>(false);
|
||||||
|
|
||||||
|
mFusedLocationClient.getLastLocation().addOnSuccessListener(
|
||||||
|
location -> {
|
||||||
|
if (location != null) {
|
||||||
|
mLastLocation = location;
|
||||||
|
coordinatesHistory.add(location);
|
||||||
|
sendCoordinateToBackend(location);
|
||||||
|
}
|
||||||
|
|
||||||
|
triggerAnotherLocationListener.set(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (triggerAnotherLocationListener.get()) {
|
||||||
|
for (String provider : providers1) {
|
||||||
|
Location location = mLocationManager.getLastKnownLocation(provider);
|
||||||
|
|
||||||
|
if (location == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (bestLocation == null || location.getAccuracy() < bestLocation.getAccuracy()) {
|
||||||
|
bestLocation = location;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
coordinatesHistory.add(bestLocation);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private void sendCoordinateToBackend(Location location) {
|
private void sendCoordinateToBackend(Location location) {
|
||||||
new Task(location).execute();
|
new Task(location).execute();
|
||||||
}
|
}
|
||||||
@ -282,48 +247,58 @@ public class BackgroundLocalizationService extends Service {
|
|||||||
|
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
mHandler.removeCallbacks(mStatusChecker);
|
mHandler.removeCallbacks(mStatusChecker);
|
||||||
destroyLocationListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void destroyLocationListeners() {
|
if (mLocationManager != null) {
|
||||||
if (mFusedLocationClient != null) {
|
for (LocationListener listener : mLocationListeners) {
|
||||||
mFusedLocationClient.removeLocationUpdates(mLocationCallback);
|
try {
|
||||||
mFusedLocationClient = null;
|
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||||
mLocationCallback = null;
|
return;
|
||||||
mLocationRequest = null;
|
}
|
||||||
|
mLocationManager.removeUpdates(listener);
|
||||||
|
|
||||||
|
} catch (Exception ex) {
|
||||||
|
Log.i(TAG, "fail to remove location listener, ignore", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateListeners() {
|
private void initializeLocationManager() {
|
||||||
if (mFusedLocationClient != null) {
|
Log.e(TAG, "initializeLocationManager - LOCATION_INTERVAL: " + LOCATION_INTERVAL + " LOCATION_DISTANCE: " + LOCATION_DISTANCE);
|
||||||
mFusedLocationClient.removeLocationUpdates(mLocationCallback)
|
|
||||||
.addOnCompleteListener(task -> {
|
if (mLocationManager == null) {
|
||||||
restartService();
|
mLocationManager = (LocationManager) getApplicationContext().getSystemService(Context.LOCATION_SERVICE);
|
||||||
mFusedLocationClient = null;
|
|
||||||
mLocationCallback = null;
|
|
||||||
mLocationRequest = null;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class LocationListener implements android.location.LocationListener {
|
||||||
|
|
||||||
private void restartService() {
|
LocationListener(String provider) {
|
||||||
|
Log.e(TAG, "LocationListener " + provider);
|
||||||
Intent stopIntent = new Intent(getApplicationContext(), BackgroundLocalizationService.class);
|
mLastLocation = new Location(provider);
|
||||||
stopIntent.putExtra("request_stop", true);
|
|
||||||
|
|
||||||
stopService(stopIntent);
|
|
||||||
|
|
||||||
Intent startIntent = new Intent(getApplicationContext(), BackgroundLocalizationService.class);
|
|
||||||
startIntent.putExtra("notify_interval", notify_interval);
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O) {
|
|
||||||
startForegroundService(startIntent);
|
|
||||||
} else {
|
|
||||||
startService(startIntent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
@Override
|
||||||
|
public void onLocationChanged(Location location) {
|
||||||
|
Log.e(TAG, "onLocationChanged: " + location);
|
||||||
|
mLastLocation.set(location);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onProviderDisabled(String provider) {
|
||||||
|
Log.e(TAG, "onProviderDisabled: " + provider);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onProviderEnabled(String provider) {
|
||||||
|
Log.e(TAG, "onProviderEnabled: " + provider);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStatusChanged(String provider, int status, Bundle extras) {
|
||||||
|
Log.e(TAG, "onStatusChanged: " + provider);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressLint("StaticFieldLeak")
|
@SuppressLint("StaticFieldLeak")
|
||||||
private class Task extends AsyncTask {
|
private class Task extends AsyncTask {
|
||||||
@ -340,7 +315,6 @@ public class BackgroundLocalizationService extends Service {
|
|||||||
latitude = location.getLatitude();
|
latitude = location.getLatitude();
|
||||||
longitude = location.getLongitude();
|
longitude = location.getLongitude();
|
||||||
altitude = location.getAltitude();
|
altitude = location.getAltitude();
|
||||||
Log.e(TAG, "TASK" + latitude + " " + longitude);
|
|
||||||
approximatedLocalization = new ApproximatedLocalization(MapUtils.loadJsonFromAsset(getApplicationContext(), "building.geojson"));
|
approximatedLocalization = new ApproximatedLocalization(MapUtils.loadJsonFromAsset(getApplicationContext(), "building.geojson"));
|
||||||
approximatedBuildingPart = approximatedLocalization.getNameOfBuildingPart(Point.fromLngLat(longitude, latitude));
|
approximatedBuildingPart = approximatedLocalization.getNameOfBuildingPart(Point.fromLngLat(longitude, latitude));
|
||||||
}
|
}
|
||||||
@ -352,11 +326,6 @@ public class BackgroundLocalizationService extends Service {
|
|||||||
String status = (PrefUtils.isStatusEnabled(getApplicationContext())) ? PrefUtils.getUserStatus(getApplicationContext()) : "";
|
String status = (PrefUtils.isStatusEnabled(getApplicationContext())) ? PrefUtils.getUserStatus(getApplicationContext()) : "";
|
||||||
|
|
||||||
if (locationLevel.equals(SharingLevel.PRESENCE.toString())) {
|
if (locationLevel.equals(SharingLevel.PRESENCE.toString())) {
|
||||||
if (!MapUtils.checkIfCoordinateIsValid(latitude, longitude)) {
|
|
||||||
coordinatesHistory.add(fakeLoc);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
latitude = presenceLatitude;
|
latitude = presenceLatitude;
|
||||||
longitude = presenceLongitude;
|
longitude = presenceLongitude;
|
||||||
approximatedBuildingPart = presenceApproximatedName;
|
approximatedBuildingPart = presenceApproximatedName;
|
||||||
@ -371,12 +340,6 @@ public class BackgroundLocalizationService extends Service {
|
|||||||
approximatedBuildingPart = PrefUtils.getManualLocationApproximation(getApplicationContext());
|
approximatedBuildingPart = PrefUtils.getManualLocationApproximation(getApplicationContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
Location fakeLoc = new Location("");
|
|
||||||
|
|
||||||
fakeLoc.setLatitude(latitude);
|
|
||||||
fakeLoc.setLongitude(longitude);
|
|
||||||
coordinatesHistory.add(fakeLoc);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Coordinate coordinate = new Coordinate(
|
Coordinate coordinate = new Coordinate(
|
||||||
latitude,
|
latitude,
|
||||||
@ -390,18 +353,18 @@ public class BackgroundLocalizationService extends Service {
|
|||||||
|
|
||||||
disposable.add(
|
disposable.add(
|
||||||
coordinateService
|
coordinateService
|
||||||
.putCoordinate(coordinate, PrefUtils.getUserId(getApplicationContext()))
|
.postCoordinate(coordinate)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribeWith(new DisposableCompletableObserver() {
|
.subscribeWith(new DisposableSingleObserver<Coordinate>() {
|
||||||
@Override
|
@Override
|
||||||
public void onComplete() {
|
public void onSuccess(Coordinate coordinate) {
|
||||||
Log.e(TAG, "CoordinateSuccess");
|
Log.e(TAG, String.valueOf(coordinate));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(Throwable e) {
|
public void onError(Throwable e) {
|
||||||
Log.e(TAG, "onErr" + valueOf(e));
|
Log.e(TAG, e.getMessage());
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
|
@ -3,7 +3,6 @@ package com.uam.wmi.findmytutor.service;
|
|||||||
import com.uam.wmi.findmytutor.model.Coordinate;
|
import com.uam.wmi.findmytutor.model.Coordinate;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import io.reactivex.Completable;
|
|
||||||
import io.reactivex.Single;
|
import io.reactivex.Single;
|
||||||
import retrofit2.http.Body;
|
import retrofit2.http.Body;
|
||||||
import retrofit2.http.DELETE;
|
import retrofit2.http.DELETE;
|
||||||
@ -25,7 +24,7 @@ public interface CoordinateService {
|
|||||||
Single<List<Coordinate>> getCoordinatesByUserId(@Path("userId") String userId);
|
Single<List<Coordinate>> getCoordinatesByUserId(@Path("userId") String userId);
|
||||||
|
|
||||||
@GET("api/coordinates/userTop/{userId}")
|
@GET("api/coordinates/userTop/{userId}")
|
||||||
Single <Coordinate> getTopCoordinateByUserId(@Path("userId") String userId);
|
Single<List<Coordinate>> getTopCoordinatesByUserId(@Path("userId") String userId);
|
||||||
|
|
||||||
@GET("api/coordinates/top")
|
@GET("api/coordinates/top")
|
||||||
Single<List<Coordinate>> getTopCoordinates();
|
Single<List<Coordinate>> getTopCoordinates();
|
||||||
@ -37,11 +36,9 @@ public interface CoordinateService {
|
|||||||
Single <Coordinate> postCoordinate(@Body Coordinate coordinate);
|
Single <Coordinate> postCoordinate(@Body Coordinate coordinate);
|
||||||
|
|
||||||
@PUT("api/coordinates/{id}")
|
@PUT("api/coordinates/{id}")
|
||||||
Completable putCoordinate(@Body Coordinate coordinate, @Path("id") String id);
|
Single<Coordinate> putCoordinatesById(@Path("id") String id);
|
||||||
|
|
||||||
@DELETE("api/coordinates/{id}")
|
@DELETE("api/coordinates/{id}")
|
||||||
Completable deleteCoordinatesById(@Path("id") String id);
|
Single<Coordinate> deleteCoordinatesById(@Path("id") String id);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
package com.uam.wmi.findmytutor.service;
|
|
||||||
|
|
||||||
import com.uam.wmi.findmytutor.model.PredefinedCoordViewModel;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import io.reactivex.Single;
|
|
||||||
import retrofit2.http.Body;
|
|
||||||
import retrofit2.http.DELETE;
|
|
||||||
import retrofit2.http.GET;
|
|
||||||
import retrofit2.http.HTTP;
|
|
||||||
import retrofit2.http.POST;
|
|
||||||
import retrofit2.http.Path;
|
|
||||||
|
|
||||||
public interface PredefinedCoordinatesService {
|
|
||||||
@GET("api/users/predefined/coordinate/{tutorId}")
|
|
||||||
Single<List<PredefinedCoordViewModel>> getUserPredefinedCoords(@Path("tutorId") String tutorId);
|
|
||||||
|
|
||||||
@POST("api/users/predefined/coordinate/{tutorId}")
|
|
||||||
Single <PredefinedCoordViewModel> postUserPredefinedCoord(@Path("tutorId") String tutorId, @Body PredefinedCoordViewModel coord);
|
|
||||||
|
|
||||||
@HTTP(method = "DELETE", path = "api/users/predefined/coordinate/{tutorId}", hasBody = true)
|
|
||||||
Single<List<PredefinedCoordViewModel>> deleteUserPredefinedCoord(@Path("tutorId") String tutorId, @Body String uuid);
|
|
||||||
}
|
|
@ -5,27 +5,25 @@ import io.reactivex.Single;
|
|||||||
import retrofit2.http.Body;
|
import retrofit2.http.Body;
|
||||||
import retrofit2.http.DELETE;
|
import retrofit2.http.DELETE;
|
||||||
import retrofit2.http.GET;
|
import retrofit2.http.GET;
|
||||||
import retrofit2.http.HTTP;
|
|
||||||
import retrofit2.http.POST;
|
import retrofit2.http.POST;
|
||||||
import retrofit2.http.Path;
|
import retrofit2.http.Path;
|
||||||
|
|
||||||
public interface PredefinedStatusesService {
|
public interface PredefinedStatusesService {
|
||||||
@GET("api/users/predefined/status/{tutorId}")
|
@GET("api/users/predefined/status/{tutorId}")
|
||||||
Single<List<String>> getUserPredefinedStatuses(@Path("tutorId") String tutorId);
|
Single<List<String>> getUserPredefinedStatuses(@Path("tutorId") String tutorId);
|
||||||
|
|
||||||
@POST("api/users/predefined/status/{tutorId}")
|
@POST("api/users/predefined/status/{tutorId}")
|
||||||
Single<List<String>> postUserPredefinedStatus(@Path("tutorId") String tutorId, @Body String status);
|
Single<List<String>> postUserPredefinedStatus(@Path("tutorId") String tutorId, @Body String status);
|
||||||
|
|
||||||
// @DELETE("api/users/predefined/status/{tutorId}")
|
@DELETE("api/users/predefined/status/{tutorId}")
|
||||||
@HTTP(method = "DELETE", path = "api/users/predefined/status/{tutorId}", hasBody = true)
|
|
||||||
Single<List<String>> deleteUserPredefinedStatus(@Path("tutorId") String tutorId, @Body String status);
|
Single<List<String>> deleteUserPredefinedStatus(@Path("tutorId") String tutorId, @Body String status);
|
||||||
|
|
||||||
/* @GET("api/users/predefined/coordinate/{tutorId}")
|
@GET("api/users/predefined/coordinate/{tutorId}")
|
||||||
Single<List<PredefinedCoordViewModel>> getUserPredefinedCoords(@Path("tutorId") String tutorId);
|
Single<List<PredefinedCoordViewModel>> getUserPredefinedCoords(@Path("tutorId") String tutorId);
|
||||||
|
|
||||||
@POST("api/users/predefined/coordinate/{tutorId}")
|
@POST("api/users/predefined/coordinate/{tutorId}")
|
||||||
Single <PredefinedCoordViewModel> postUserPredefinedCoord(@Path("tutorId") String tutorId, @Body PredefinedCoordViewModel coord);
|
Single <PredefinedCoordViewModel> postUserPredefinedCoord(@Path("tutorId") String tutorId, @Body PredefinedCoordViewModel coord);
|
||||||
|
|
||||||
@DELETE("api/users/predefined/coordinate/{tutorId}")
|
@DELETE("api/users/predefined/coordinate/{tutorId}")
|
||||||
Single<List<PredefinedCoordViewModel>> deleteUserPredefinedCoord(@Path("tutorId") String tutorId, @Body PredefinedCoordViewModel coord);*/
|
Single<List<PredefinedCoordViewModel>> deleteUserPredefinedCoord(@Path("tutorId") String tutorId, @Body PredefinedCoordViewModel coord);
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,8 @@ package com.uam.wmi.findmytutor.service;
|
|||||||
|
|
||||||
import com.uam.wmi.findmytutor.model.TutorTabViewModel;
|
import com.uam.wmi.findmytutor.model.TutorTabViewModel;
|
||||||
|
|
||||||
import io.reactivex.Completable;
|
|
||||||
import io.reactivex.Observable;
|
import io.reactivex.Observable;
|
||||||
import io.reactivex.Single;
|
import io.reactivex.Single;
|
||||||
import retrofit2.Response;
|
|
||||||
import retrofit2.http.*;
|
import retrofit2.http.*;
|
||||||
|
|
||||||
|
|
||||||
@ -18,7 +16,7 @@ public interface TutorTabApi {
|
|||||||
* @return Call<Void>
|
* @return Call<Void>
|
||||||
*/
|
*/
|
||||||
@POST("api/users/scrapTutorTab/{tutorId}")
|
@POST("api/users/scrapTutorTab/{tutorId}")
|
||||||
Completable apiUsersScrapTutorTabByTutorIdPost(
|
Observable<Void> apiUsersScrapTutorTabByTutorIdPost(
|
||||||
@retrofit2.http.Path("tutorId") String tutorId
|
@retrofit2.http.Path("tutorId") String tutorId
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -28,7 +26,7 @@ public interface TutorTabApi {
|
|||||||
* @return Call<Void>
|
* @return Call<Void>
|
||||||
*/
|
*/
|
||||||
@POST("api/users/scrapTutorTab")
|
@POST("api/users/scrapTutorTab")
|
||||||
Single<Void> apiUsersScrapTutorTabPost();
|
Observable<Void> apiUsersScrapTutorTabPost();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,10 +40,6 @@ public interface TutorTabApi {
|
|||||||
@retrofit2.http.Path("tutorId") String tutorId
|
@retrofit2.http.Path("tutorId") String tutorId
|
||||||
);
|
);
|
||||||
|
|
||||||
@POST("api/users/tutorTab/{tutorId}")
|
|
||||||
Single<TutorTabViewModel> apiUsersTutorTabByTutorIdPost(
|
|
||||||
@retrofit2.http.Path("tutorId") String tutorId, @retrofit2.http.Body TutorTabViewModel tutorTab
|
|
||||||
);
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
@ -57,7 +51,7 @@ public interface TutorTabApi {
|
|||||||
"Content-Type:application/json"
|
"Content-Type:application/json"
|
||||||
})
|
})
|
||||||
@PUT("api/users/tutorTab/{tutorId}")
|
@PUT("api/users/tutorTab/{tutorId}")
|
||||||
Observable<Response<Void>> apiUsersTutorTabByTutorIdPut(
|
Observable<TutorTabViewModel> apiUsersTutorTabByTutorIdPut(
|
||||||
@retrofit2.http.Path("tutorId") String tutorId, @retrofit2.http.Body TutorTabViewModel tutorTab
|
@retrofit2.http.Path("tutorId") String tutorId, @retrofit2.http.Body TutorTabViewModel tutorTab
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -10,17 +10,14 @@ import java.util.List;
|
|||||||
|
|
||||||
import io.reactivex.Completable;
|
import io.reactivex.Completable;
|
||||||
import io.reactivex.Observable;
|
import io.reactivex.Observable;
|
||||||
import io.reactivex.ObservableEmitter;
|
|
||||||
import io.reactivex.Single;
|
import io.reactivex.Single;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
import retrofit2.http.Body;
|
import retrofit2.http.Body;
|
||||||
import retrofit2.http.DELETE;
|
import retrofit2.http.DELETE;
|
||||||
import retrofit2.http.GET;
|
import retrofit2.http.GET;
|
||||||
import retrofit2.http.HTTP;
|
|
||||||
import retrofit2.http.POST;
|
import retrofit2.http.POST;
|
||||||
import retrofit2.http.PUT;
|
import retrofit2.http.PUT;
|
||||||
import retrofit2.http.Path;
|
import retrofit2.http.Path;
|
||||||
import retrofit2.http.Query;
|
|
||||||
|
|
||||||
|
|
||||||
public interface UserService {
|
public interface UserService {
|
||||||
@ -33,21 +30,6 @@ public interface UserService {
|
|||||||
@GET("api/users/tutors")
|
@GET("api/users/tutors")
|
||||||
Single <List<User>> getAllTutors();
|
Single <List<User>> getAllTutors();
|
||||||
|
|
||||||
@GET("api/users/tutors/online")
|
|
||||||
Single <List<User>> getAllOnlineTutors();
|
|
||||||
|
|
||||||
@GET("api/users/tutors/active")
|
|
||||||
Single <List<User>> getAllActiveTutors();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@GET("api/users/tutors/offline")
|
|
||||||
Single <List<User>> getAllOfflineTutors();
|
|
||||||
|
|
||||||
@GET("api/users/tutors/search")
|
|
||||||
Single <List<User>> searchUser(@Query(value = "searchString", encoded = true) String searchString);
|
|
||||||
|
|
||||||
@POST("api/users")
|
@POST("api/users")
|
||||||
Completable createUser(@Body User user);
|
Completable createUser(@Body User user);
|
||||||
|
|
||||||
@ -63,9 +45,6 @@ public interface UserService {
|
|||||||
@GET("api/users/{id}")
|
@GET("api/users/{id}")
|
||||||
Single <User> getUserById(@Path("id") String userID);
|
Single <User> getUserById(@Path("id") String userID);
|
||||||
|
|
||||||
@GET("api/users/self/{id}")
|
|
||||||
Single <User> getSelf(@Path("id") String userID);
|
|
||||||
|
|
||||||
@PUT("api/users/{id}")
|
@PUT("api/users/{id}")
|
||||||
Completable updateUserByID(@Path("id") String userID, @Body User user);
|
Completable updateUserByID(@Path("id") String userID, @Body User user);
|
||||||
|
|
||||||
@ -82,28 +61,26 @@ public interface UserService {
|
|||||||
Completable setUserInActive(@Path("userID") String userID);
|
Completable setUserInActive(@Path("userID") String userID);
|
||||||
|
|
||||||
@GET("api/users/blacklist/{tutorID}")
|
@GET("api/users/blacklist/{tutorID}")
|
||||||
Single <List<String>> getTutorBlacklistedByID(@Path("tutorID") String tutorID);
|
Single<List<User>> getTutorBlacklistedByID(@Path("tutorID") String tutorID);
|
||||||
|
|
||||||
@PUT("api/users/blacklist/{tutorID}")
|
@PUT("api/users/blacklist/{tutorID}")
|
||||||
Completable setTutorBlacklist(@Path("tutorID") String tutorID, @Body IsUsingListBool isUsing);
|
Completable setTutorBlacklist(@Path("tutorID") String tutorID, @Body IsUsingListBool isUsing);
|
||||||
|
|
||||||
@POST("api/users/blacklist/{tutorID}")
|
@POST("api/users/blacklist/{tutorID}")
|
||||||
Observable <User> addStudentToBlacklist(@Path("tutorID") String tutorID, @Body StudentIdModel student);
|
Completable addStudentToBlacklist(@Path("tutorID") String tutorID, @Body StudentIdModel student);
|
||||||
|
|
||||||
// @DELETE("api/users/blacklist/{tutorID}")
|
@DELETE("api/users/blacklist/{tutorID}")
|
||||||
@HTTP(method = "DELETE", path = "api/users/blacklist/{tutorID}", hasBody = true)
|
|
||||||
Completable removeStudentFromBlacklist(@Path("tutorID") String tutorID, @Body StudentIdModel student);
|
Completable removeStudentFromBlacklist(@Path("tutorID") String tutorID, @Body StudentIdModel student);
|
||||||
|
|
||||||
@GET("api/users/whitelist/{tutorID}")
|
@GET("api/users/whitelist/{tutorID}")
|
||||||
Single<List<String>> getTutorWhitelistedByID(@Path("tutorID") String tutorID);
|
Single<List<User>> getTutorwhitelistedByID(@Path("tutorID") String tutorID);
|
||||||
|
|
||||||
@PUT("api/users/whitelist/{tutorID}")
|
@PUT("api/users/whitelist/{tutorID}")
|
||||||
Completable setTutorWhitelist(@Path("tutorID") String tutorID, @Body IsUsingListBool isUsing);
|
Completable setTutorWhitelist(@Path("tutorID") String tutorID, @Body IsUsingListBool isUsing);
|
||||||
|
|
||||||
@POST("api/users/whitelist/{tutorID}")
|
@POST("api/users/whitelist/{tutorID}")
|
||||||
Observable <User> addStudentToWhitelist(@Path("tutorID") String tutorID, @Body StudentIdModel student);
|
Completable addStudentTowhitelist(@Path("tutorID") String tutorID, @Body StudentIdModel student);
|
||||||
|
|
||||||
// @DELETE("api/users/whitelist/{tutorID}")
|
@DELETE("api/users/whitelist/{tutorID}")
|
||||||
@HTTP(method = "DELETE", path = "api/users/whitelist/{tutorID}", hasBody = true)
|
|
||||||
Completable removeStudentFromWhitelist(@Path("tutorID") String tutorID, @Body StudentIdModel student);
|
Completable removeStudentFromWhitelist(@Path("tutorID") String tutorID, @Body StudentIdModel student);
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,25 @@
|
|||||||
package com.uam.wmi.findmytutor.utils;
|
package com.uam.wmi.findmytutor.utils;
|
||||||
|
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
|
import com.google.gson.GsonBuilder;
|
||||||
|
import com.mapbox.geojson.BoundingBox;
|
||||||
import com.mapbox.geojson.Feature;
|
import com.mapbox.geojson.Feature;
|
||||||
import com.mapbox.geojson.FeatureCollection;
|
import com.mapbox.geojson.FeatureCollection;
|
||||||
|
import com.mapbox.geojson.Geometry;
|
||||||
import com.mapbox.geojson.Point;
|
import com.mapbox.geojson.Point;
|
||||||
import com.mapbox.geojson.Polygon;
|
import com.mapbox.geojson.Polygon;
|
||||||
import com.mapbox.turf.TurfClassification;
|
import com.mapbox.geojson.gson.BoundingBoxDeserializer;
|
||||||
|
import com.mapbox.geojson.gson.GeoJsonAdapterFactory;
|
||||||
|
import com.mapbox.geojson.gson.GeometryDeserializer;
|
||||||
|
import com.mapbox.geojson.gson.PointDeserializer;
|
||||||
import com.mapbox.turf.TurfJoins;
|
import com.mapbox.turf.TurfJoins;
|
||||||
import com.mapbox.turf.TurfMeasurement;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
;import static com.mapbox.geojson.FeatureCollection.fromJson;
|
;
|
||||||
|
|
||||||
public class ApproximatedLocalization {
|
public class ApproximatedLocalization {
|
||||||
private FeatureCollection buildingSchema = null;
|
private FeatureCollection buildingSchema = null;
|
||||||
@ -21,6 +28,17 @@ public class ApproximatedLocalization {
|
|||||||
buildingSchema = fromJson(buildingObject);
|
buildingSchema = fromJson(buildingObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private FeatureCollection fromJson(@NonNull String json) {
|
||||||
|
GsonBuilder gson = new GsonBuilder();
|
||||||
|
|
||||||
|
gson.registerTypeAdapterFactory(GeoJsonAdapterFactory.create());
|
||||||
|
gson.registerTypeAdapter(Point.class, new PointDeserializer());
|
||||||
|
gson.registerTypeAdapter(Geometry.class, new GeometryDeserializer());
|
||||||
|
gson.registerTypeAdapter(BoundingBox.class, new BoundingBoxDeserializer());
|
||||||
|
|
||||||
|
return gson.create().fromJson(json, FeatureCollection.class);
|
||||||
|
}
|
||||||
|
|
||||||
public String getNameOfBuildingPart(Point point) {
|
public String getNameOfBuildingPart(Point point) {
|
||||||
|
|
||||||
for (Feature feature : Objects.requireNonNull(buildingSchema.features())) {
|
for (Feature feature : Objects.requireNonNull(buildingSchema.features())) {
|
||||||
@ -38,9 +56,7 @@ public class ApproximatedLocalization {
|
|||||||
for (Feature feature : Objects.requireNonNull(buildingSchema.features())) {
|
for (Feature feature : Objects.requireNonNull(buildingSchema.features())) {
|
||||||
String partName = feature.getStringProperty("name");
|
String partName = feature.getStringProperty("name");
|
||||||
|
|
||||||
|
|
||||||
if (buildingPart != null && buildingPart.equals(partName)) {
|
if (buildingPart != null && buildingPart.equals(partName)) {
|
||||||
|
|
||||||
Double longitude = feature.getNumberProperty("longitude").doubleValue();
|
Double longitude = feature.getNumberProperty("longitude").doubleValue();
|
||||||
Double latitude = feature.getNumberProperty("latitude").doubleValue();
|
Double latitude = feature.getNumberProperty("latitude").doubleValue();
|
||||||
|
|
||||||
|
@ -6,10 +6,8 @@ import java.util.Arrays;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Const {
|
public class Const {
|
||||||
public final static String BASE_URL = "https://s416084.projektstudencki.pl/master/";
|
public final static Integer onlineBackgroundLocationInterval = 15000;
|
||||||
public final static Integer mapRefreshInterval = 6000;
|
public final static Integer offlineBackgroundLocationInterval = 36000;
|
||||||
public final static Integer onlineBackgroundLocationInterval = 7000;
|
|
||||||
public final static Integer offlineBackgroundLocationInterval = 360000;
|
|
||||||
public final static Integer defaultMapZoom = 17;
|
public final static Integer defaultMapZoom = 17;
|
||||||
public final static Integer searchMapZoom = 13;
|
public final static Integer searchMapZoom = 13;
|
||||||
public final static Double presenceLatitude = 52.466365;
|
public final static Double presenceLatitude = 52.466365;
|
||||||
@ -17,10 +15,8 @@ public class Const {
|
|||||||
public final static String presenceApproximatedName = "Unknown";
|
public final static String presenceApproximatedName = "Unknown";
|
||||||
public final static Range<Double> buildingLatitudeRange = Range.create(52.466092, 52.467529);
|
public final static Range<Double> buildingLatitudeRange = Range.create(52.466092, 52.467529);
|
||||||
public final static Range<Double> buildingLongitudeRange = Range.create(16.926159, 16.927759);
|
public final static Range<Double> buildingLongitudeRange = Range.create(16.926159, 16.927759);
|
||||||
public final static Range<Double> outsideLatitudeRange = Range.create(52.4651, 52.468837);
|
public final static Range<Double> outsideLatitudeRange = Range.create(52.463512, 52.468837);
|
||||||
public final static Range<Double> outsideLongitudeRange = Range.create(16.9186, 16.936004);
|
public final static Range<Double> outsideLongitudeRange = Range.create(16.922372, 16.936004);
|
||||||
public final static List<String> validApproximatedLocations = Arrays.asList("Skrzydło B", "Skrzydło A", "Aule", "Łącznik", "Biblioteka", "Hol", "Unknown");
|
public final static List<String> validApproximatedLocations = Arrays.asList("Skrzydło B", "Skrzydło A", "Aule", "Łącznik", "Biblioteka", "Hol", "Unknown");
|
||||||
public final static String WMI_SSID_NAME = "wmi";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
package com.uam.wmi.findmytutor.utils;
|
|
||||||
|
|
||||||
import android.app.Dialog;
|
|
||||||
import android.app.DialogFragment;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.v7.app.AlertDialog;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.uam.wmi.findmytutor.R;
|
|
||||||
import com.uam.wmi.findmytutor.activity.MapActivity;
|
|
||||||
|
|
||||||
public class EnableSharingDialog extends DialogFragment {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
|
||||||
return new AlertDialog.Builder(getActivity())
|
|
||||||
.setTitle(R.string.sharing_modal_title)
|
|
||||||
.setMessage(R.string.enable_sharing_question)
|
|
||||||
.setPositiveButton(R.string.possitive_dialog_button, (dialog, which) ->
|
|
||||||
dialogPositiveAnswer(getActivity())
|
|
||||||
)
|
|
||||||
.setNegativeButton(R.string.negative_dialog_button, (dialog, which) -> dialog.cancel()).create();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void dialogPositiveAnswer(Context context) {
|
|
||||||
PrefUtils.storeEnableSharingLocalization(context, true);
|
|
||||||
((MapActivity) getActivity()).handleBackgroundTaskLifeCycle();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
package com.uam.wmi.findmytutor.utils;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.drawable.ColorDrawable;
|
|
||||||
import android.view.Gravity;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.PopupWindow;
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext;
|
|
||||||
|
|
||||||
public class InfoHelperUtils {
|
|
||||||
|
|
||||||
public static void infoPopUp(View anchorView, int layoutId) {
|
|
||||||
LayoutInflater layoutInflater = (LayoutInflater)getApplicationContext().getSystemService( Context.LAYOUT_INFLATER_SERVICE );
|
|
||||||
View popupView = Objects.requireNonNull(layoutInflater).inflate(layoutId, null);
|
|
||||||
|
|
||||||
PopupWindow popupWindow = new PopupWindow(popupView,
|
|
||||||
LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
|
|
||||||
// If the PopupWindow should be focusable
|
|
||||||
popupWindow.setFocusable(true);
|
|
||||||
// If you need the PopupWindow to dismiss when when touched outside
|
|
||||||
popupWindow.setBackgroundDrawable(new ColorDrawable());
|
|
||||||
int location[] = new int[2];
|
|
||||||
// Get the View's(the one that was clicked in the Fragment) location
|
|
||||||
anchorView.getLocationOnScreen(location);
|
|
||||||
// Using location, the PopupWindow will be displayed right under anchorView
|
|
||||||
popupWindow.showAtLocation(anchorView, Gravity.NO_GRAVITY,
|
|
||||||
location[0] + anchorView.getWidth() / 2, location[1] + anchorView.getHeight());
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,80 +0,0 @@
|
|||||||
package com.uam.wmi.findmytutor.utils;
|
|
||||||
|
|
||||||
|
|
||||||
import android.annotation.TargetApi;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.content.res.Configuration;
|
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
public class LocaleHelper {
|
|
||||||
|
|
||||||
private static final String SELECTED_LANGUAGE = "Locale.Helper.Selected.Language";
|
|
||||||
|
|
||||||
public static Context onAttach(Context context) {
|
|
||||||
String lang = getPersistedData(context, Locale.getDefault().getLanguage());
|
|
||||||
return setLocale(context, lang);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Context onAttach(Context context, String defaultLanguage) {
|
|
||||||
String lang = getPersistedData(context, defaultLanguage);
|
|
||||||
return setLocale(context, lang);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getLanguage(Context context) {
|
|
||||||
return getPersistedData(context, Locale.getDefault().getLanguage());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Context setLocale(Context context, String language) {
|
|
||||||
persist(context, language);
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
|
||||||
return updateResources(context, language);
|
|
||||||
}
|
|
||||||
|
|
||||||
return updateResourcesLegacy(context, language);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String getPersistedData(Context context, String defaultLanguage) {
|
|
||||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
|
||||||
return preferences.getString(SELECTED_LANGUAGE, defaultLanguage);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void persist(Context context, String language) {
|
|
||||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
|
||||||
SharedPreferences.Editor editor = preferences.edit();
|
|
||||||
|
|
||||||
editor.putString(SELECTED_LANGUAGE, language);
|
|
||||||
editor.apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.N)
|
|
||||||
private static Context updateResources(Context context, String language) {
|
|
||||||
Locale locale = new Locale(language);
|
|
||||||
Locale.setDefault(locale);
|
|
||||||
|
|
||||||
Configuration configuration = context.getResources().getConfiguration();
|
|
||||||
configuration.setLocale(locale);
|
|
||||||
|
|
||||||
return context.createConfigurationContext(configuration);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
private static Context updateResourcesLegacy(Context context, String language) {
|
|
||||||
Locale locale = new Locale(language);
|
|
||||||
Locale.setDefault(locale);
|
|
||||||
|
|
||||||
Resources resources = context.getResources();
|
|
||||||
|
|
||||||
Configuration configuration = resources.getConfiguration();
|
|
||||||
configuration.locale = locale;
|
|
||||||
|
|
||||||
resources.updateConfiguration(configuration, resources.getDisplayMetrics());
|
|
||||||
|
|
||||||
return context;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,32 +1,15 @@
|
|||||||
package com.uam.wmi.findmytutor.utils;
|
package com.uam.wmi.findmytutor.utils;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Configuration;
|
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.support.v4.os.ConfigurationCompat;
|
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
public class LocaleUtils {
|
public class LocaleUtils {
|
||||||
public static String getCurrentLocale() {
|
public static String getCurrentLocale(Context context){
|
||||||
return String.valueOf(ConfigurationCompat.getLocales(Resources.getSystem().getConfiguration()));
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N){
|
||||||
}
|
return String.valueOf(context.getResources().getConfiguration().getLocales().get(0));
|
||||||
|
} else{
|
||||||
private static Context updateResources(Context context, String language) {
|
//noinspection deprecation
|
||||||
Locale locale = new Locale(language);
|
return String.valueOf(context.getResources().getConfiguration().locale);
|
||||||
Locale.setDefault(locale);
|
|
||||||
|
|
||||||
Resources res = context.getResources();
|
|
||||||
Configuration config = new Configuration(res.getConfiguration());
|
|
||||||
if (Build.VERSION.SDK_INT >= 22) {
|
|
||||||
config.setLocale(locale);
|
|
||||||
context = context.createConfigurationContext(config);
|
|
||||||
} else {
|
|
||||||
config.locale = locale;
|
|
||||||
res.updateConfiguration(config, res.getDisplayMetrics());
|
|
||||||
}
|
}
|
||||||
return context;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +1,8 @@
|
|||||||
package com.uam.wmi.findmytutor.utils;
|
package com.uam.wmi.findmytutor.utils;
|
||||||
|
|
||||||
import android.animation.TypeEvaluator;
|
import android.animation.TypeEvaluator;
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
import android.net.Uri;
|
|
||||||
import android.provider.Settings;
|
|
||||||
|
|
||||||
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||||
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
||||||
@ -14,15 +10,12 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
|
|||||||
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
|
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
|
||||||
import com.mapbox.mapboxsdk.maps.MapView;
|
import com.mapbox.mapboxsdk.maps.MapView;
|
||||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||||
import com.uam.wmi.findmytutor.R;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext;
|
|
||||||
import static com.uam.wmi.findmytutor.utils.Const.outsideLatitudeRange;
|
|
||||||
import static com.uam.wmi.findmytutor.utils.Const.outsideLongitudeRange;
|
import static com.uam.wmi.findmytutor.utils.Const.outsideLongitudeRange;
|
||||||
import static com.uam.wmi.findmytutor.utils.PrefUtils.shouldBatteryExclusionBeShown;
|
import static com.uam.wmi.findmytutor.utils.Const.outsideLatitudeRange;
|
||||||
|
|
||||||
public class MapUtils {
|
public class MapUtils {
|
||||||
|
|
||||||
@ -48,8 +41,8 @@ public class MapUtils {
|
|||||||
|
|
||||||
// Map Bounds Area
|
// Map Bounds Area
|
||||||
public static void setZoom(MapboxMap mapboxMap, Integer zoom) {
|
public static void setZoom(MapboxMap mapboxMap, Integer zoom) {
|
||||||
makeNewCamera(mapboxMap, 52.466799, 16.927002, zoom, 0, 0, 1000);
|
makeNewCamera(mapboxMap, 52.466799, 16.927002, zoom, 0, 0, 1000);
|
||||||
mapboxMap.setMinZoomPreference(16); // TODO export to map config
|
mapboxMap.setMinZoomPreference(16); // TODO export to map config
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void makeNewCamera(MapboxMap mapboxMap, double lat, double lon, int zoomParam, int bearingParam, int tiltParam, int duration) {
|
public static void makeNewCamera(MapboxMap mapboxMap, double lat, double lon, int zoomParam, int bearingParam, int tiltParam, int duration) {
|
||||||
@ -80,32 +73,8 @@ public class MapUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Boolean checkIfCoordinateIsValid(Location coordinate) {
|
public static Boolean checkIfCoordinateIsValid(Location coordinate){
|
||||||
return outsideLatitudeRange.contains(coordinate.getLatitude()) && outsideLongitudeRange.contains(coordinate.getLongitude());
|
return outsideLatitudeRange.contains(coordinate.getLatitude()) && outsideLongitudeRange.contains(coordinate.getLongitude());
|
||||||
}
|
|
||||||
|
|
||||||
public static Boolean checkIfCoordinateIsValid(Double latitude, Double longitude) {
|
|
||||||
return Const.buildingLatitudeRange.contains(latitude) && Const.buildingLongitudeRange.contains(longitude);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void BatteryOptimizationsExceptionCheck(Context context) {
|
|
||||||
if (shouldBatteryExclusionBeShown(getApplicationContext())) {
|
|
||||||
PrefUtils.setBatteryExlusionInfoStatus(getApplicationContext(), false);
|
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
|
||||||
builder.setTitle(R.string.batter_exclusions_title);
|
|
||||||
builder.setMessage(R.string.batter_exclusions_message)
|
|
||||||
.setPositiveButton(R.string.ok, (dialog, id) -> {
|
|
||||||
Intent intent = new Intent();
|
|
||||||
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
|
||||||
Uri uri = Uri.fromParts("package", getApplicationContext().getPackageName(), null);
|
|
||||||
intent.setData(uri);
|
|
||||||
context.startActivity(intent);
|
|
||||||
})
|
|
||||||
.setNegativeButton(R.string.cancel, (dialog, id) -> {
|
|
||||||
|
|
||||||
}).show();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function for marker animation
|
// Function for marker animation
|
||||||
|
@ -60,19 +60,9 @@ public class PrefUtils {
|
|||||||
return getSharedPreferences(context).getBoolean("key_status_enabled", false);
|
return getSharedPreferences(context).getBoolean("key_status_enabled", false);
|
||||||
|
|
||||||
}
|
}
|
||||||
public static void enableStatus(Context context){
|
|
||||||
SharedPreferences.Editor editor = getSharedPreferences(context).edit();
|
|
||||||
editor.putBoolean("key_status_enabled", true);
|
|
||||||
editor.apply();
|
|
||||||
}
|
|
||||||
public static void disableStatus(Context context) {
|
|
||||||
SharedPreferences.Editor editor = getSharedPreferences(context).edit();
|
|
||||||
editor.putBoolean("key_status_enabled", false);
|
|
||||||
editor.apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getUserStatus(Context context) {
|
public static String getUserStatus(Context context) {
|
||||||
return getSharedPreferences(context).getString("status_entry", "Dostępny");
|
return getSharedPreferences(context).getString("status_entry", "Available");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void storeStatus(Context context, String status) {
|
public static void storeStatus(Context context, String status) {
|
||||||
@ -104,11 +94,6 @@ public class PrefUtils {
|
|||||||
public static boolean isEnableSharingLocalization(Context context) {
|
public static boolean isEnableSharingLocalization(Context context) {
|
||||||
return getSharedPreferences(context).getBoolean("key_sharing_enabled", false);
|
return getSharedPreferences(context).getBoolean("key_sharing_enabled", false);
|
||||||
}
|
}
|
||||||
public static void disableSharing(Context context){
|
|
||||||
SharedPreferences.Editor editor = getSharedPreferences(context).edit();
|
|
||||||
editor.putBoolean("key_sharing_enabled", false);
|
|
||||||
editor.apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void storeEnableSharingLocalization(Context context, Boolean isChecked) {
|
public static void storeEnableSharingLocalization(Context context, Boolean isChecked) {
|
||||||
SharedPreferences.Editor editor = getSharedPreferences(context).edit();
|
SharedPreferences.Editor editor = getSharedPreferences(context).edit();
|
||||||
@ -159,7 +144,7 @@ public class PrefUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String getLocale(Context context) {
|
public static String getLocale(Context context) {
|
||||||
return getSharedPreferences(context).getString("LOCALE", LocaleUtils.getCurrentLocale());
|
return getSharedPreferences(context).getString("LOCALE", LocaleUtils.getCurrentLocale(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Boolean isBackgroundLocationServiceRunning(Context context) {
|
public static Boolean isBackgroundLocationServiceRunning(Context context) {
|
||||||
@ -177,7 +162,7 @@ public class PrefUtils {
|
|||||||
editor.putString("key_location_level","3");
|
editor.putString("key_location_level","3");
|
||||||
editor.putString("location_mode", "manual");
|
editor.putString("location_mode", "manual");
|
||||||
editor.putString("approx_manual_loc", approximatedLocation);
|
editor.putString("approx_manual_loc", approximatedLocation);
|
||||||
/*editor.putBoolean("key_sharing_enabled", true);*/
|
editor.putBoolean("key_sharing_enabled", true);
|
||||||
editor.putLong("longitude_manual_location", Double.doubleToRawLongBits(latLng.getLongitude()));
|
editor.putLong("longitude_manual_location", Double.doubleToRawLongBits(latLng.getLongitude()));
|
||||||
editor.putLong("latitude_manual_location", Double.doubleToRawLongBits(latLng.getLatitude()));
|
editor.putLong("latitude_manual_location", Double.doubleToRawLongBits(latLng.getLatitude()));
|
||||||
editor.apply();
|
editor.apply();
|
||||||
@ -203,53 +188,5 @@ public class PrefUtils {
|
|||||||
public static String getCurrentManualLocation(Context context) {
|
public static String getCurrentManualLocation(Context context) {
|
||||||
return getSharedPreferences(context).getString("current_manual_location", null);
|
return getSharedPreferences(context).getString("current_manual_location", null);
|
||||||
}
|
}
|
||||||
public static void putCurrentManualLocationName(Context context, String locationName) {
|
|
||||||
SharedPreferences.Editor editor = getSharedPreferences(context).edit();
|
|
||||||
editor.putString("current_manual_location_name", locationName);
|
|
||||||
editor.apply();
|
|
||||||
}
|
|
||||||
public static String getCurrentManualLocationName(Context context) {
|
|
||||||
return getSharedPreferences(context).getString("current_manual_location_name", null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void putShowOnlyOnlineUsers(Context context, Boolean flag) {
|
|
||||||
SharedPreferences.Editor editor = getSharedPreferences(context).edit();
|
|
||||||
editor.putBoolean("show_only_online_users_in_list", flag);
|
|
||||||
editor.apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Boolean getShowOnlyOnlineUsers(Context context) {
|
|
||||||
return getSharedPreferences(context).getBoolean("show_only_online_users_in_list", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void useBlacklist(Context context, Boolean flag) {
|
|
||||||
SharedPreferences.Editor editor = getSharedPreferences(context).edit();
|
|
||||||
editor.putBoolean("blacklisting", flag);
|
|
||||||
editor.putBoolean("whitelisting", false);
|
|
||||||
editor.apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void useWhitelist(Context context, Boolean flag) {
|
|
||||||
SharedPreferences.Editor editor = getSharedPreferences(context).edit();
|
|
||||||
editor.putBoolean("whitelisting", flag);
|
|
||||||
editor.putBoolean("blacklisting", false);
|
|
||||||
editor.apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Boolean isBlackListing(Context context) {
|
|
||||||
return getSharedPreferences(context).getBoolean("blacklisting", false);
|
|
||||||
}
|
|
||||||
public static Boolean isWhiteListing(Context context) {
|
|
||||||
return getSharedPreferences(context).getBoolean("whitelisting", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Boolean shouldBatteryExclusionBeShown(Context context) {
|
|
||||||
return getSharedPreferences(context).getBoolean("show_battery_exclusion", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setBatteryExlusionInfoStatus(Context context, Boolean flag) {
|
|
||||||
SharedPreferences.Editor editor = getSharedPreferences(context).edit();
|
|
||||||
editor.putBoolean("show_battery_exclusion", flag);
|
|
||||||
editor.apply();
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -2,8 +2,6 @@ package com.uam.wmi.findmytutor.utils;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
@ -11,63 +9,31 @@ import com.uam.wmi.findmytutor.R;
|
|||||||
|
|
||||||
public class RightButtonPreference extends Preference {
|
public class RightButtonPreference extends Preference {
|
||||||
|
|
||||||
private Button prefButton;
|
|
||||||
private String buttonText;
|
|
||||||
|
|
||||||
public RightButtonPreference(Context context, AttributeSet attrs) {
|
public RightButtonPreference(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
setWidgetLayoutResource(R.layout.preference_button_widget);
|
setWidgetLayoutResource(R.layout.preference_button_widget);
|
||||||
init(context, attrs);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void init(Context context, AttributeSet attrs){
|
|
||||||
for (int i=0;i<attrs.getAttributeCount();i++) {
|
|
||||||
String attr = attrs.getAttributeName(i);
|
|
||||||
try {
|
|
||||||
if(attr.equalsIgnoreCase("key")){
|
|
||||||
Log.e("BUTTON_ERR",attr);
|
|
||||||
String val = attrs.getAttributeValue(i);
|
|
||||||
|
|
||||||
switch (val) {
|
|
||||||
case "remove_manual_status":
|
|
||||||
buttonText = context.getResources().getString(R.string.preference_manual_location_button_remove);
|
|
||||||
break;
|
|
||||||
case "manual_location_button":
|
|
||||||
buttonText = context.getResources().getString(R.string.preference_manual_location_button);
|
|
||||||
break;
|
|
||||||
case "remove_manual_location":
|
|
||||||
buttonText = context.getResources().getString(R.string.preference_manual_location_button_remove);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
buttonText = "";
|
|
||||||
Log.e("BUTTON_ERR", String.valueOf(e));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void setText(String text){
|
|
||||||
prefButton.setText(text);
|
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
protected View onCreateView(ViewGroup parent) {
|
protected View onCreateView(ViewGroup parent) {
|
||||||
return super.onCreateView(parent);
|
View view = super.onCreateView(parent);
|
||||||
|
// LayoutInflater li = (LayoutInflater)getContext().getSystemService( Context.LAYOUT_INFLATER_SERVICE );
|
||||||
|
// View temp =li.inflate( R.layout.preference_button_widget, parent, false);
|
||||||
|
return view;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
protected void onBindView(View view)
|
protected void onBindView(View view)
|
||||||
{
|
{
|
||||||
super.onBindView(view);
|
super.onBindView(view);
|
||||||
prefButton = view.findViewById(R.id.button_choose_from_map);
|
Button button = (Button)view.findViewById(R.id.button_choose_from_map);
|
||||||
prefButton.setText(buttonText);
|
if(button != null)
|
||||||
if(prefButton != null)
|
|
||||||
{
|
{
|
||||||
prefButton.setOnClickListener(view1 -> {
|
button.setOnClickListener(new View.OnClickListener() {
|
||||||
callChangeListener(null);
|
@Override
|
||||||
notifyChanged();
|
public void onClick(View view) {
|
||||||
});
|
callChangeListener(null);
|
||||||
|
notifyChanged();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,13 +1,16 @@
|
|||||||
package com.uam.wmi.findmytutor.utils;
|
package com.uam.wmi.findmytutor.utils;
|
||||||
|
|
||||||
|
|
||||||
import android.support.v7.widget.SearchView;
|
import android.support.v7.widget.SearchView;
|
||||||
|
|
||||||
import io.reactivex.Observable;
|
import io.reactivex.Observable;
|
||||||
import io.reactivex.subjects.PublishSubject;
|
import io.reactivex.subjects.PublishSubject;
|
||||||
|
|
||||||
|
|
||||||
public class RxSearchObservable {
|
public class RxSearchObservable {
|
||||||
|
|
||||||
private RxSearchObservable() {
|
private RxSearchObservable() {
|
||||||
|
// no instance
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Observable<String> fromView(SearchView searchView) {
|
public static Observable<String> fromView(SearchView searchView) {
|
||||||
@ -18,7 +21,6 @@ public class RxSearchObservable {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onQueryTextSubmit(String s) {
|
public boolean onQueryTextSubmit(String s) {
|
||||||
subject.onNext(s);
|
subject.onNext(s);
|
||||||
searchView.clearFocus();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,8 +29,11 @@ public class RxSearchObservable {
|
|||||||
subject.onNext(text);
|
subject.onNext(text);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
return subject;
|
return subject;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,44 +0,0 @@
|
|||||||
package com.uam.wmi.findmytutor.utils;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.drawable.ColorDrawable;
|
|
||||||
import android.preference.Preference;
|
|
||||||
import android.util.AttributeSet;
|
|
||||||
import android.view.Gravity;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.ImageButton;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.PopupWindow;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.uam.wmi.findmytutor.R;
|
|
||||||
|
|
||||||
import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext;
|
|
||||||
|
|
||||||
public class SharingInfoPopupButtonPreference extends Preference {
|
|
||||||
|
|
||||||
public SharingInfoPopupButtonPreference(Context context, AttributeSet attrs) {
|
|
||||||
super(context, attrs);
|
|
||||||
setWidgetLayoutResource(R.layout.preference_popup_info_button_widget);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
protected View onCreateView(ViewGroup parent) {
|
|
||||||
View view = super.onCreateView(parent);
|
|
||||||
// LayoutInflater li = (LayoutInflater)getContext().getSystemService( Context.LAYOUT_INFLATER_SERVICE );
|
|
||||||
// View temp =li.inflate( R.layout.preference_button_widget, parent, false);
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
protected void onBindView(View view)
|
|
||||||
{
|
|
||||||
super.onBindView(view);
|
|
||||||
ImageButton button = view.findViewById(R.id.sharingTabInfoImageButton);
|
|
||||||
button.setOnClickListener(v-> {
|
|
||||||
InfoHelperUtils.infoPopUp(v,R.layout.info_popup_sharing_tab);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
package com.uam.wmi.findmytutor.utils;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.net.NetworkInfo;
|
|
||||||
import android.net.wifi.WifiInfo;
|
|
||||||
import android.net.wifi.WifiManager;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class WifiUtils {
|
|
||||||
|
|
||||||
public static String getWifiName(Context context) {
|
|
||||||
WifiManager manager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
|
|
||||||
if (Objects.requireNonNull(manager).isWifiEnabled()) {
|
|
||||||
WifiInfo wifiInfo = manager.getConnectionInfo();
|
|
||||||
if (wifiInfo != null) {
|
|
||||||
NetworkInfo.DetailedState state = WifiInfo.getDetailedStateOf(wifiInfo.getSupplicantState());
|
|
||||||
if (state == NetworkInfo.DetailedState.CONNECTED || state == NetworkInfo.DetailedState.OBTAINING_IPADDR) {
|
|
||||||
return wifiInfo.getSSID();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Boolean checkIfUserIsInRangeOfWmiWifi(Context context) {
|
|
||||||
return Objects.equals(getWifiName(context), Const.WMI_SSID_NAME);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
package com.uam.wmi.findmytutor.utils;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
|
||||||
import android.support.v7.widget.RecyclerView;
|
|
||||||
import android.util.AttributeSet;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
public class WrapContentLinearLayoutManager extends LinearLayoutManager {
|
|
||||||
public WrapContentLinearLayoutManager(Context context) {
|
|
||||||
super(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {
|
|
||||||
try {
|
|
||||||
super.onLayoutChildren(recycler, state);
|
|
||||||
} catch (IndexOutOfBoundsException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Before Width: | Height: | Size: 381 B |
Before Width: | Height: | Size: 447 B |
Before Width: | Height: | Size: 660 B |
Before Width: | Height: | Size: 830 B |
Before Width: | Height: | Size: 259 B |
Before Width: | Height: | Size: 306 B |
Before Width: | Height: | Size: 447 B |
Before Width: | Height: | Size: 595 B |
Before Width: | Height: | Size: 447 B |
Before Width: | Height: | Size: 595 B |
Before Width: | Height: | Size: 830 B |
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 660 B |
Before Width: | Height: | Size: 830 B |
Before Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 830 B |
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 2.3 KiB |
@ -1,13 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:width="24dp"
|
|
||||||
android:height="24dp"
|
|
||||||
android:viewportWidth="24"
|
|
||||||
android:viewportHeight="24">
|
|
||||||
|
|
||||||
<path
|
|
||||||
android:pathData="M0 0h24v24H0z" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#FFFFFF"
|
|
||||||
android:pathData="M15 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm-9-2V7H4v3H1v2h3v3h2v-3h3v-2H6zm9 4c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z" />
|
|
||||||
</vector>
|
|
@ -1,9 +1,9 @@
|
|||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:width="24dp"
|
android:width="24dp"
|
||||||
android:height="24dp"
|
android:height="24dp"
|
||||||
android:viewportHeight="24.0"
|
android:viewportHeight="24.0"
|
||||||
android:viewportWidth="24.0">
|
android:viewportWidth="24.0">
|
||||||
<path
|
<path
|
||||||
android:fillColor="#FF000000"
|
android:fillColor="#FF000000"
|
||||||
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zm1,15h-2v-6h2v6zm0,-8h-2V7h2v2z" />
|
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zm1,15h-2v-6h2v6zm0,-8h-2V7h2v2z" />
|
||||||
</vector>
|
</vector>
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
<solid android:color="#ffffff"/>
|
|
||||||
<stroke android:width="3dp" android:color="#b1bcbe" />
|
|
||||||
<corners android:radius="10dp"/>
|
|
||||||
<padding android:left="0dp" android:top="0dp" android:right="0dp" android:bottom="0dp" />
|
|
||||||
</shape>
|
|
@ -1,10 +0,0 @@
|
|||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:width="24dp"
|
|
||||||
android:height="24dp"
|
|
||||||
android:viewportWidth="24.0"
|
|
||||||
android:viewportHeight="24.0"
|
|
||||||
android:tint="?attr/colorControlNormal">
|
|
||||||
<path
|
|
||||||
android:fillColor="@android:color/white"
|
|
||||||
android:pathData="M11,7h2v2h-2zM11,11h2v6h-2zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8z"/>
|
|
||||||
</vector>
|
|
@ -1,15 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:width="24dp"
|
|
||||||
android:height="24dp"
|
|
||||||
android:viewportWidth="24"
|
|
||||||
android:viewportHeight="24">
|
|
||||||
|
|
||||||
<path
|
|
||||||
android:pathData="M0 0h24v24H0z" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#FFFF"
|
|
||||||
android:pathData="M2 12C2 6.48 6.48 2 12 2s10 4.48 10 10-4.48 10-10 10S2 17.52 2 12zm10 6c3.31 0 6-2.69 6-6s-2.69-6-6-6-6 2.69-6 6 2.69 6 6 6z" />
|
|
||||||
<path
|
|
||||||
android:pathData="M0 0h24v24H0z" />
|
|
||||||
</vector>
|
|
@ -1,13 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:width="24dp"
|
|
||||||
android:height="24dp"
|
|
||||||
android:viewportWidth="24"
|
|
||||||
android:viewportHeight="24">
|
|
||||||
|
|
||||||
<path
|
|
||||||
android:fillColor="#ffffff"
|
|
||||||
android:pathData="M22 10l-6-6H4c-1.1 0-2 0.9-2 2v12.01c0 1.1 0.9 1.99 2 1.99l16-0.01c1.1 0 2-0.89 2-1.99v-8zm-7-4.5l5.5 5.5H15V5.5z" />
|
|
||||||
<path
|
|
||||||
android:pathData="M0 0h24v24H0V0z" />
|
|
||||||
</vector>
|
|
@ -1,83 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:fitsSystemWindows="true"
|
|
||||||
android:id="@+id/activity_blacklist_container"
|
|
||||||
tools:context=".activity.BlackList">
|
|
||||||
|
|
||||||
<android.support.design.widget.AppBarLayout
|
|
||||||
android:id="@+id/app_bar"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="@dimen/app_bar_height"
|
|
||||||
android:fitsSystemWindows="true"
|
|
||||||
android:theme="@style/AppTheme.AppBarOverlay">
|
|
||||||
|
|
||||||
<android.support.design.widget.CollapsingToolbarLayout
|
|
||||||
android:id="@+id/toolbar_layout"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:fitsSystemWindows="true"
|
|
||||||
app:contentScrim="?attr/colorPrimary"
|
|
||||||
app:layout_scrollFlags="scroll|exitUntilCollapsed"
|
|
||||||
app:expandedTitleGravity="top|right"
|
|
||||||
app:toolbarId="@+id/toolbar"
|
|
||||||
>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:gravity="left|bottom"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:padding="10dp"
|
|
||||||
android:layout_marginBottom="20dp"
|
|
||||||
app:layout_collapseMode="parallax">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tv_title"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:text="@string/block_the_users"
|
|
||||||
android:textSize="15sp"/>
|
|
||||||
|
|
||||||
<Switch
|
|
||||||
android:id="@+id/switch_blacklist_toggle"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:thumbTextPadding="45dp"
|
|
||||||
android:text="BLACKLIST TEXT SWITCH" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<android.support.v7.widget.Toolbar
|
|
||||||
android:id="@+id/toolbar"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="?attr/actionBarSize"
|
|
||||||
app:layout_collapseMode="pin"
|
|
||||||
app:popupTheme="@style/AppTheme.PopupOverlay"
|
|
||||||
/>
|
|
||||||
|
|
||||||
</android.support.design.widget.CollapsingToolbarLayout>
|
|
||||||
</android.support.design.widget.AppBarLayout>
|
|
||||||
|
|
||||||
<include layout="@layout/content_black_list" />
|
|
||||||
|
|
||||||
<android.support.design.widget.FloatingActionButton
|
|
||||||
android:id="@+id/add_to_black_list_fab"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_margin="@dimen/fab_margin"
|
|
||||||
android:layout_marginTop="-322dp"
|
|
||||||
app:layout_anchor="@id/app_bar"
|
|
||||||
app:layout_anchorGravity="bottom|end"
|
|
||||||
app:srcCompat="@drawable/ic_add_person"
|
|
||||||
app:useCompatPadding="true"
|
|
||||||
tools:srcCompat="@tools:sample/backgrounds/scenic" />
|
|
||||||
|
|
||||||
<!-- A RecyclerView with some commonly used attributes -->
|
|
||||||
|
|
||||||
|
|
||||||
</android.support.design.widget.CoordinatorLayout>
|
|
@ -4,13 +4,13 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:fontFamily="@font/lato_regular"
|
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
|
||||||
android:paddingTop="@dimen/activity_vertical_margin"
|
|
||||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
|
||||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||||
|
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingTop="@dimen/activity_vertical_margin"
|
||||||
|
android:fontFamily="@font/lato_regular"
|
||||||
tools:context=".activity.LoginActivity">
|
tools:context=".activity.LoginActivity">
|
||||||
|
|
||||||
|
|
||||||
@ -58,7 +58,6 @@
|
|||||||
|
|
||||||
<android.support.design.widget.TextInputLayout
|
<android.support.design.widget.TextInputLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
app:passwordToggleEnabled="true"
|
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
@ -75,6 +74,7 @@
|
|||||||
|
|
||||||
</android.support.design.widget.TextInputLayout>
|
</android.support.design.widget.TextInputLayout>
|
||||||
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/email_sign_in_button"
|
android:id="@+id/email_sign_in_button"
|
||||||
style="?android:textAppearanceSmall"
|
style="?android:textAppearanceSmall"
|
||||||
@ -84,6 +84,7 @@
|
|||||||
android:text="@string/action_log_in"
|
android:text="@string/action_log_in"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -2,6 +2,7 @@
|
|||||||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:mapbox="http://schemas.android.com/apk/res-auto"
|
xmlns:mapbox="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:fab="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
@ -21,13 +22,12 @@
|
|||||||
</com.mapbox.mapboxsdk.maps.MapView>
|
</com.mapbox.mapboxsdk.maps.MapView>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/linearLayout2"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:gravity="bottom"
|
android:gravity="bottom"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
tools:layout_editor_absoluteX="0dp"
|
tools:layout_editor_absoluteX="0dp"
|
||||||
tools:layout_editor_absoluteY="0dp">
|
tools:layout_editor_absoluteY="1dp">
|
||||||
|
|
||||||
<!-- Implementation of find my location button -->
|
<!-- Implementation of find my location button -->
|
||||||
|
|
||||||
|
@ -5,29 +5,30 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:fontFamily="@font/lato_regular"
|
android:fontFamily="@font/lato_regular"
|
||||||
android:id="@+id/activity_tutor_tab"
|
|
||||||
tools:context=".activity.TutorTab">
|
tools:context=".activity.TutorTab">
|
||||||
|
|
||||||
<android.support.design.widget.AppBarLayout
|
<android.support.design.widget.AppBarLayout
|
||||||
android:id="@+id/app_bar"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/app_bar_height"
|
android:layout_height="wrap_content"
|
||||||
android:fitsSystemWindows="true"
|
|
||||||
android:theme="@style/AppTheme.AppBarOverlay">
|
android:theme="@style/AppTheme.AppBarOverlay">
|
||||||
|
|
||||||
<android.support.design.widget.CollapsingToolbarLayout
|
<android.support.v7.widget.Toolbar
|
||||||
android:id="@+id/toolbar_layout"
|
android:id="@+id/toolbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="?attr/actionBarSize"
|
||||||
android:fitsSystemWindows="true"
|
android:background="?attr/colorPrimary"
|
||||||
app:contentScrim="?attr/colorPrimary"
|
app:popupTheme="@style/AppTheme.PopupOverlay" />
|
||||||
app:layout_scrollFlags="scroll|exitUntilCollapsed"
|
|
||||||
app:expandedTitleGravity="top|right"
|
|
||||||
app:toolbarId="@+id/toolbar"
|
|
||||||
/>
|
|
||||||
|
|
||||||
</android.support.design.widget.AppBarLayout>
|
</android.support.design.widget.AppBarLayout>
|
||||||
|
|
||||||
<include layout="@layout/content_tutor_tab" />
|
<include layout="@layout/content_tutor_tab" />
|
||||||
|
|
||||||
|
<android.support.design.widget.FloatingActionButton
|
||||||
|
android:id="@+id/fab"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="bottom|end"
|
||||||
|
android:layout_margin="@dimen/fab_margin"
|
||||||
|
app:srcCompat="@android:drawable/ic_dialog_email" />
|
||||||
|
|
||||||
</android.support.design.widget.CoordinatorLayout>
|
</android.support.design.widget.CoordinatorLayout>
|
@ -1,83 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:fitsSystemWindows="true"
|
|
||||||
android:id="@+id/activity_whitelist_container"
|
|
||||||
tools:context=".activity.WhiteList">
|
|
||||||
|
|
||||||
<android.support.design.widget.AppBarLayout
|
|
||||||
android:id="@+id/app_bar"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="@dimen/app_bar_height"
|
|
||||||
android:fitsSystemWindows="true"
|
|
||||||
android:theme="@style/AppTheme.AppBarOverlay">
|
|
||||||
|
|
||||||
<android.support.design.widget.CollapsingToolbarLayout
|
|
||||||
android:id="@+id/toolbar_layout"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:fitsSystemWindows="true"
|
|
||||||
app:contentScrim="?attr/colorPrimary"
|
|
||||||
app:layout_scrollFlags="scroll|exitUntilCollapsed"
|
|
||||||
app:expandedTitleGravity="top|right"
|
|
||||||
app:toolbarId="@+id/toolbar"
|
|
||||||
>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:gravity="left|bottom"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:padding="10dp"
|
|
||||||
android:layout_marginBottom="20dp"
|
|
||||||
app:layout_collapseMode="parallax">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tv_title"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:text="@string/be_visible_for_these_users"
|
|
||||||
android:textSize="15sp"/>
|
|
||||||
|
|
||||||
<Switch
|
|
||||||
android:id="@+id/switch_whitelist_toggle"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:thumbTextPadding="45dp"
|
|
||||||
android:text="WHITELIST TEXT SWITCH" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<android.support.v7.widget.Toolbar
|
|
||||||
android:id="@+id/toolbar"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="?attr/actionBarSize"
|
|
||||||
app:layout_collapseMode="pin"
|
|
||||||
app:popupTheme="@style/AppTheme.PopupOverlay"
|
|
||||||
/>
|
|
||||||
|
|
||||||
</android.support.design.widget.CollapsingToolbarLayout>
|
|
||||||
</android.support.design.widget.AppBarLayout>
|
|
||||||
|
|
||||||
<include layout="@layout/content_white_list" />
|
|
||||||
|
|
||||||
<android.support.design.widget.FloatingActionButton
|
|
||||||
android:id="@+id/add_to_white_list_fab"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_margin="@dimen/fab_margin"
|
|
||||||
android:layout_marginTop="-322dp"
|
|
||||||
app:layout_anchor="@id/app_bar"
|
|
||||||
app:layout_anchorGravity="bottom|end"
|
|
||||||
app:srcCompat="@drawable/ic_add_person"
|
|
||||||
app:useCompatPadding="true"
|
|
||||||
tools:srcCompat="@tools:sample/backgrounds/scenic" />
|
|
||||||
|
|
||||||
<!-- A RecyclerView with some commonly used attributes -->
|
|
||||||
|
|
||||||
|
|
||||||
</android.support.design.widget.CoordinatorLayout>
|
|
@ -1,42 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:fontFamily="@font/lato_regular"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
|
||||||
android:paddingTop="@dimen/activity_vertical_margin"
|
|
||||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
|
||||||
android:paddingBottom="@dimen/activity_vertical_margin">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/black_list_modal_title"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignStart="@+id/black_list_modal_input"
|
|
||||||
android:layout_marginBottom="@dimen/dimen_10"
|
|
||||||
android:fontFamily="sans-serif-medium"
|
|
||||||
android:lineSpacingExtra="8sp"
|
|
||||||
android:text="@string/black_list_title"
|
|
||||||
android:textColor="@color/colorAccent"
|
|
||||||
android:textSize="@dimen/lbl_new_note_title"
|
|
||||||
android:textStyle="normal" />
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/black_list_modal_input"
|
|
||||||
android:layout_width="315dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignParentTop="true"
|
|
||||||
android:layout_centerHorizontal="true"
|
|
||||||
android:layout_marginTop="50dp"
|
|
||||||
android:ems="10"
|
|
||||||
android:hint="@string/index_user"
|
|
||||||
android:maxLength="30"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:requiresFadingEdge="vertical"
|
|
||||||
android:scrollbars="vertical"
|
|
||||||
android:textColor="@color/note_list_text" />
|
|
||||||
|
|
||||||
|
|
||||||
</RelativeLayout>
|
|
@ -1,48 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="90dp"
|
|
||||||
android:clickable="true"
|
|
||||||
android:focusable="true"
|
|
||||||
android:paddingLeft="10dp"
|
|
||||||
android:paddingTop="@dimen/dimen_10"
|
|
||||||
android:paddingRight="10dp"
|
|
||||||
android:fontFamily="@font/lato_regular"
|
|
||||||
android:paddingBottom="@dimen/dimen_10">
|
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/firstName"
|
|
||||||
android:layout_width="271dp"
|
|
||||||
android:layout_height="22dp"
|
|
||||||
android:layout_alignParentStart="true"
|
|
||||||
android:layout_alignParentTop="true"
|
|
||||||
android:layout_marginStart="12dp"
|
|
||||||
android:layout_marginTop="10dp"
|
|
||||||
android:textColor="@color/note_list_text"
|
|
||||||
android:textSize="15sp" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/lastName"
|
|
||||||
android:layout_width="270dp"
|
|
||||||
android:layout_height="22dp"
|
|
||||||
android:layout_below="@+id/firstName"
|
|
||||||
android:layout_alignEnd="@+id/firstName"
|
|
||||||
android:layout_marginTop="10dp"
|
|
||||||
android:layout_marginEnd="0dp"
|
|
||||||
android:textColor="@color/note_list_text"
|
|
||||||
android:textSize="15sp" />
|
|
||||||
|
|
||||||
|
|
||||||
<ImageButton
|
|
||||||
android:id="@+id/removeUserImageButton"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_below="@+id/firstName"
|
|
||||||
android:layout_toEndOf="@+id/firstName"
|
|
||||||
android:background="@null"
|
|
||||||
android:layout_alignParentEnd="true"
|
|
||||||
app:srcCompat="@drawable/abc_ic_clear_material" />
|
|
||||||
|
|
||||||
</RelativeLayout>
|
|
@ -1,48 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
|
|
||||||
|
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
|
||||||
tools:context=".activity.UsersListFragment"
|
|
||||||
android:fontFamily="@font/lato_regular"
|
|
||||||
tools:showIn="@layout/users_list_main">
|
|
||||||
|
|
||||||
|
|
||||||
<android.support.v7.widget.RecyclerView
|
|
||||||
android:id="@+id/recycler_view_blacklist"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/black_list_empty_text_view"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_centerHorizontal="true"
|
|
||||||
android:layout_marginTop="@dimen/margin_top_no_notes"
|
|
||||||
android:fontFamily="sans-serif-light"
|
|
||||||
android:text="@string/loading"
|
|
||||||
android:textColor="@color/msg_no_notes"
|
|
||||||
android:textSize="@dimen/msg_no_notes" />
|
|
||||||
|
|
||||||
<com.github.ybq.android.spinkit.SpinKitView
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:id="@+id/loader"
|
|
||||||
style="@style/SpinKitView.Large.Wave"
|
|
||||||
android:layout_width="150dp"
|
|
||||||
android:layout_height="150dp"
|
|
||||||
app:SpinKit_Color="@color/msg_no_notes"
|
|
||||||
android:layout_centerHorizontal="true"
|
|
||||||
android:layout_marginTop="@dimen/margin_top_no_notes"
|
|
||||||
android:fontFamily="sans-serif-light"
|
|
||||||
android:text="@string/loading"
|
|
||||||
android:textColor="@color/msg_no_notes"
|
|
||||||
android:textSize="@dimen/msg_no_notes" />
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</RelativeLayout>
|
|
||||||
|
|
@ -1,61 +1,85 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:fontFamily="@font/lato_regular"
|
||||||
|
android:paddingLeft="@dimen/activity_margin"
|
||||||
|
android:paddingRight="@dimen/activity_margin"
|
||||||
|
android:paddingTop="@dimen/activity_margin">
|
||||||
|
|
||||||
|
<TextView android:id="@+id/userName"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="@dimen/dimen_10"
|
||||||
|
android:fontFamily="sans-serif-medium"
|
||||||
|
android:lineSpacingExtra="8sp"
|
||||||
|
android:textColor="@color/mapboxRedDark"
|
||||||
|
android:textSize="@dimen/lbl_new_note_title"
|
||||||
|
android:textStyle="normal" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/userDepartment"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:fitsSystemWindows="true"
|
android:lineSpacingExtra="8sp"
|
||||||
android:id="@+id/activity_tutor_content"
|
android:paddingTop="5dp"
|
||||||
tools:context=".activity.TutorTab">
|
android:textColor="@color/note_list_text"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
<android.support.design.widget.AppBarLayout
|
android:id="@+id/userRoom"
|
||||||
android:id="@+id/app_bar"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="132dp"
|
android:layout_height="wrap_content"
|
||||||
android:fitsSystemWindows="true"
|
android:lineSpacingExtra="8sp"
|
||||||
android:theme="@style/AppTheme.AppBarOverlay">
|
android:paddingTop="5dp"
|
||||||
|
android:textColor="@color/note_list_text"
|
||||||
|
/>
|
||||||
|
|
||||||
<android.support.design.widget.CollapsingToolbarLayout
|
<TextView
|
||||||
android:id="@+id/toolbar_layout"
|
android:id="@+id/userEmail"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:fitsSystemWindows="true"
|
android:lineSpacingExtra="8sp"
|
||||||
app:contentScrim="?attr/colorPrimary"
|
android:paddingTop="5dp"
|
||||||
app:expandedTitleGravity="top|right"
|
android:textColor="@color/note_list_text" />
|
||||||
app:layout_scrollFlags="scroll|exitUntilCollapsed"
|
|
||||||
app:toolbarId="@+id/toolbar">
|
|
||||||
|
|
||||||
<LinearLayout
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:id="@+id/userDutyHours"
|
||||||
android:layout_height="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_marginBottom="20dp"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="left|bottom"
|
android:lineSpacingExtra="8sp"
|
||||||
android:orientation="vertical"
|
android:paddingTop="5dp"
|
||||||
android:padding="10dp"
|
android:textColor="@color/note_list_text"
|
||||||
app:layout_collapseMode="parallax">
|
tools:text="@string/dutyHours" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/userName"
|
android:id="@+id/userNoteTitle"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentRight="true"
|
android:paddingTop="0dp"
|
||||||
android:text="User Name"
|
android:paddingBottom="0dp"
|
||||||
android:textSize="22sp" />
|
android:paddingStart="@dimen/activity_margin"
|
||||||
|
android:textColor="@color/note_list_text" />
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/userNote"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="150dp"
|
||||||
|
android:lineSpacingExtra="8sp"
|
||||||
|
android:paddingTop="5dp"
|
||||||
|
android:textColor="@color/note_list_text"
|
||||||
|
android:hint="@string/tutorTabHint"
|
||||||
|
android:inputType="textMultiLine"
|
||||||
|
android:maxLength="1000"
|
||||||
|
android:maxLines="7"
|
||||||
|
android:requiresFadingEdge="vertical"
|
||||||
|
android:scrollbars="vertical"/>
|
||||||
|
|
||||||
</LinearLayout>
|
<Button
|
||||||
|
android:id="@+id/saveButon"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/saveButton" />
|
||||||
|
|
||||||
<android.support.v7.widget.Toolbar
|
</LinearLayout>
|
||||||
android:id="@+id/toolbar"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="?attr/actionBarSize"
|
|
||||||
app:layout_collapseMode="pin"
|
|
||||||
app:popupTheme="@style/AppTheme.PopupOverlay" />
|
|
||||||
|
|
||||||
</android.support.design.widget.CollapsingToolbarLayout>
|
|
||||||
|
|
||||||
</android.support.design.widget.AppBarLayout>
|
|
||||||
|
|
||||||
<include layout="@layout/content_tutor_tab_layout" />
|
|
||||||
|
|
||||||
</android.support.design.widget.CoordinatorLayout>
|
|
@ -1,215 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
|
|
||||||
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:fillViewport="true"
|
|
||||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
|
||||||
tools:context=".activity.TutorTab"
|
|
||||||
android:fontFamily="@font/lato_regular"
|
|
||||||
tools:showIn="@layout/content_tutor_tab">
|
|
||||||
|
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:fontFamily="@font/lato_regular"
|
|
||||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
|
||||||
tools:context=".activity.TutorTab">
|
|
||||||
|
|
||||||
<android.support.design.widget.TextInputLayout
|
|
||||||
android:id="@+id/userDepartmentLayout"
|
|
||||||
android:layout_width="189dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_below="@+id/userEmailLayout"
|
|
||||||
android:layout_alignParentEnd="true"
|
|
||||||
android:layout_marginStart="25dp"
|
|
||||||
android:layout_marginTop="10dp"
|
|
||||||
android:layout_marginEnd="30dp"
|
|
||||||
android:layout_toEndOf="@+id/userRoomLayout">
|
|
||||||
|
|
||||||
<android.support.design.widget.TextInputEditText
|
|
||||||
android:id="@+id/userDepartment"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_below="@+id/userDepartmentLayout"
|
|
||||||
android:layout_alignStart="@+id/userDepartmentLayout"
|
|
||||||
android:layout_alignTop="@+id/userDepartmentLayout"
|
|
||||||
android:hint="@string/hint_department"
|
|
||||||
android:inputType="text"
|
|
||||||
android:lineSpacingExtra="8sp"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:paddingTop="5dp"
|
|
||||||
android:textColor="@color/note_list_text" />
|
|
||||||
</android.support.design.widget.TextInputLayout>
|
|
||||||
|
|
||||||
<android.support.design.widget.TextInputLayout
|
|
||||||
android:id="@+id/userRoomLayout"
|
|
||||||
android:layout_width="115dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_below="@+id/userEmailLayout"
|
|
||||||
android:layout_alignParentStart="true"
|
|
||||||
android:layout_marginStart="30dp"
|
|
||||||
android:layout_marginTop="10dp">
|
|
||||||
|
|
||||||
<android.support.design.widget.TextInputEditText
|
|
||||||
android:id="@+id/userRoom"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
|
|
||||||
android:layout_below="@+id/userRoomLayout"
|
|
||||||
android:layout_alignTop="@+id/userRoomLayout"
|
|
||||||
android:hint="@string/hint_room"
|
|
||||||
android:inputType="text"
|
|
||||||
android:lineSpacingExtra="8sp"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:paddingTop="5dp"
|
|
||||||
android:textColor="@color/note_list_text" />
|
|
||||||
</android.support.design.widget.TextInputLayout>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/personalInfoTitle"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignStart="@+id/userRoomLayout"
|
|
||||||
android:layout_alignParentTop="true"
|
|
||||||
android:layout_marginTop="30dp"
|
|
||||||
android:layout_marginStart="5dp"
|
|
||||||
android:text="@string/personalInfoTitle"
|
|
||||||
android:textColor="@color/mapboxRedDark"
|
|
||||||
android:textSize="18sp"
|
|
||||||
android:textStyle="bold" />
|
|
||||||
|
|
||||||
<android.support.design.widget.TextInputLayout
|
|
||||||
android:id="@+id/userEmailLayout"
|
|
||||||
android:layout_width="326dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignParentStart="true"
|
|
||||||
android:layout_alignParentTop="true"
|
|
||||||
android:layout_alignParentEnd="true"
|
|
||||||
android:layout_marginStart="30dp"
|
|
||||||
android:layout_marginTop="70dp"
|
|
||||||
android:layout_marginEnd="30dp">
|
|
||||||
|
|
||||||
<android.support.design.widget.TextInputEditText
|
|
||||||
android:id="@+id/userEmail"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignStart="@+id/userEmailLayout"
|
|
||||||
android:layout_alignTop="@+id/userEmailLayout"
|
|
||||||
android:hint="@string/hint_email"
|
|
||||||
android:inputType="textEmailAddress"
|
|
||||||
android:lineSpacingExtra="8sp"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:paddingTop="5dp"
|
|
||||||
android:textColor="@color/note_list_text" />
|
|
||||||
</android.support.design.widget.TextInputLayout>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/dutyTitle"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_below="@+id/userRoomLayout"
|
|
||||||
android:layout_alignStart="@+id/userRoomLayout"
|
|
||||||
android:layout_marginStart="5dp"
|
|
||||||
android:layout_marginEnd="30dp"
|
|
||||||
android:layout_marginTop="10dp"
|
|
||||||
android:gravity="center"
|
|
||||||
android:text="@string/dutyTitle"
|
|
||||||
android:textColor="@color/mapboxRedDark"
|
|
||||||
android:textSize="18sp"
|
|
||||||
android:textStyle="bold" />
|
|
||||||
|
|
||||||
<android.support.v7.widget.RecyclerView
|
|
||||||
android:id="@+id/dutyHourView"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="120dp"
|
|
||||||
android:layout_below="@+id/addDuty"
|
|
||||||
android:layout_alignParentStart="true"
|
|
||||||
android:layout_marginStart="30dp"
|
|
||||||
android:layout_marginTop="15dp"
|
|
||||||
android:layout_marginEnd="50dp"
|
|
||||||
android:scrollbars="vertical" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/userNoteTitle"
|
|
||||||
android:textStyle="bold"
|
|
||||||
android:layout_marginStart="5dp"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_below="@+id/dutyHourView"
|
|
||||||
android:layout_alignStart="@+id/userRoomLayout"
|
|
||||||
android:text="@string/userNoteTitle"
|
|
||||||
android:textColor="@color/mapboxRedDark"
|
|
||||||
android:textSize="18sp" />
|
|
||||||
|
|
||||||
<android.support.v7.widget.AppCompatButton
|
|
||||||
android:id="@+id/addDuty"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textColor="@color/white"
|
|
||||||
app:backgroundTint="@color/colorPrimary"
|
|
||||||
android:layout_alignBaseline="@+id/dutyTitle"
|
|
||||||
android:layout_toEndOf="@+id/dutyTitle"
|
|
||||||
android:stateListAnimator="@null"
|
|
||||||
|
|
||||||
android:text="@string/addDuty" />
|
|
||||||
|
|
||||||
<android.support.design.widget.TextInputLayout
|
|
||||||
android:id="@+id/userNoteLayout"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_below="@+id/userNoteTitle"
|
|
||||||
android:layout_alignParentStart="true"
|
|
||||||
android:layout_marginStart="30dp"
|
|
||||||
android:layout_marginEnd="30dp"
|
|
||||||
android:layout_marginTop="15dp"
|
|
||||||
app:counterEnabled="true"
|
|
||||||
app:counterMaxLength="1000">
|
|
||||||
|
|
||||||
<android.support.design.widget.TextInputEditText
|
|
||||||
android:id="@+id/userNote"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="100dp"
|
|
||||||
android:layout_alignStart="@+id/userNoteLayout"
|
|
||||||
android:hint="@string/tutorTabHint"
|
|
||||||
android:inputType="textMultiLine"
|
|
||||||
android:lineSpacingExtra="8sp"
|
|
||||||
android:maxLength="1000"
|
|
||||||
android:maxLines="7"
|
|
||||||
android:paddingTop="15dp"
|
|
||||||
android:requiresFadingEdge="vertical"
|
|
||||||
android:scrollbars="vertical"
|
|
||||||
android:textColor="@color/note_list_text" />
|
|
||||||
</android.support.design.widget.TextInputLayout>
|
|
||||||
|
|
||||||
<android.support.v7.widget.AppCompatButton
|
|
||||||
android:id="@+id/scrapTutorTab"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignBaseline="@+id/personalInfoTitle"
|
|
||||||
android:layout_alignEnd="@+id/userEmailLayout"
|
|
||||||
android:textColor="@color/white"
|
|
||||||
app:backgroundTint="@color/colorPrimary"
|
|
||||||
android:stateListAnimator="@null"
|
|
||||||
android:text="@string/scrap_tutor_tab" />
|
|
||||||
|
|
||||||
<android.support.v7.widget.AppCompatButton
|
|
||||||
android:id="@+id/saveButton"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginStart="30dp"
|
|
||||||
android:layout_marginEnd="-20dp"
|
|
||||||
android:layout_below="@+id/userNoteLayout"
|
|
||||||
android:layout_alignEnd="@+id/dutyHourView"
|
|
||||||
android:textColor="@color/white"
|
|
||||||
app:backgroundTint="@color/colorPrimary"
|
|
||||||
android:stateListAnimator="@null"
|
|
||||||
|
|
||||||
android:text="@string/saveButton" />
|
|
||||||
|
|
||||||
</RelativeLayout>
|
|
||||||
</android.support.v4.widget.NestedScrollView>
|
|
@ -1,47 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
|
|
||||||
|
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
|
||||||
tools:context=".activity.UsersListFragment"
|
|
||||||
android:fontFamily="@font/lato_regular"
|
|
||||||
tools:showIn="@layout/users_list_main">
|
|
||||||
|
|
||||||
|
|
||||||
<android.support.v7.widget.RecyclerView
|
|
||||||
android:id="@+id/recycler_view_whitelist"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/white_list_empty_text_view"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_centerHorizontal="true"
|
|
||||||
android:layout_marginTop="@dimen/margin_top_no_notes"
|
|
||||||
android:fontFamily="sans-serif-light"
|
|
||||||
android:text="@string/loading"
|
|
||||||
android:textColor="@color/msg_no_notes"
|
|
||||||
android:textSize="@dimen/msg_no_notes" />
|
|
||||||
|
|
||||||
<com.github.ybq.android.spinkit.SpinKitView
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:id="@+id/loader"
|
|
||||||
style="@style/SpinKitView.Large.Wave"
|
|
||||||
android:layout_width="150dp"
|
|
||||||
android:layout_height="150dp"
|
|
||||||
app:SpinKit_Color="@color/msg_no_notes"
|
|
||||||
android:layout_centerHorizontal="true"
|
|
||||||
android:layout_marginTop="@dimen/margin_top_no_notes"
|
|
||||||
android:fontFamily="sans-serif-light"
|
|
||||||
android:text="@string/loading"
|
|
||||||
android:textColor="@color/msg_no_notes"
|
|
||||||
android:textSize="@dimen/msg_no_notes" />
|
|
||||||
|
|
||||||
|
|
||||||
</RelativeLayout>
|
|
||||||
|
|
@ -1,65 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<android.support.design.widget.TextInputLayout
|
|
||||||
android:id="@+id/duty_day"
|
|
||||||
android:layout_width="95dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:hint="@string/hint_duty_day">
|
|
||||||
|
|
||||||
<android.support.design.widget.TextInputEditText
|
|
||||||
android:id="@+id/duty_day_value"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:inputType="text"
|
|
||||||
android:maxLines="1"
|
|
||||||
tools:text="@tools:sample/date/day_of_week" />
|
|
||||||
</android.support.design.widget.TextInputLayout>
|
|
||||||
|
|
||||||
<android.support.design.widget.TextInputLayout
|
|
||||||
android:id="@+id/duty_start"
|
|
||||||
android:layout_width="65dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:hint="@string/hint_duty_start">
|
|
||||||
|
|
||||||
<android.support.design.widget.TextInputEditText
|
|
||||||
android:id="@+id/duty_start_value"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:inputType="text"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
tools:text="@tools:sample/date/hhmm"
|
|
||||||
android:focusableInTouchMode="false"
|
|
||||||
/>
|
|
||||||
</android.support.design.widget.TextInputLayout>
|
|
||||||
|
|
||||||
<android.support.design.widget.TextInputLayout
|
|
||||||
android:id="@+id/duty_stop"
|
|
||||||
android:layout_width="65dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:hint="@string/hint_duty_end">
|
|
||||||
|
|
||||||
<android.support.design.widget.TextInputEditText
|
|
||||||
android:id="@+id/duty_stop_value"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:inputType="text"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
tools:text="@tools:sample/date/hhmm"
|
|
||||||
android:focusableInTouchMode="false"
|
|
||||||
/>
|
|
||||||
</android.support.design.widget.TextInputLayout>
|
|
||||||
|
|
||||||
<ImageButton
|
|
||||||
android:id="@+id/deleteRow"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:scaleX="0.7"
|
|
||||||
android:scaleY="0.7"
|
|
||||||
app:srcCompat="@android:drawable/ic_delete" />
|
|
||||||
</LinearLayout>
|
|
@ -3,8 +3,8 @@
|
|||||||
android:id="@android:id/text1"
|
android:id="@android:id/text1"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceListItemSmall"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:textSize="14sp"
|
android:textSize="16sp"
|
||||||
android:paddingTop="2dp"
|
|
||||||
android:fontFamily="@font/lato_regular"
|
android:fontFamily="@font/lato_regular"
|
||||||
android:textColor="@color/mapboxWhite" />
|
android:textColor="@color/mapboxWhite" />
|
@ -1,13 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="vertical">
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textView"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_centerInParent="true"
|
|
||||||
android:text="Homw Tab"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"/>
|
|
||||||
</RelativeLayout>
|
|
@ -1,39 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:background="@drawable/layout_bg"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:padding="10dp"
|
|
||||||
android:textColor="@color/half_black">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textViewP1_info_icon_blacklist_p1"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="5dp"
|
|
||||||
android:layout_marginTop="5dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="@string/info_icon_blacklist_p1"
|
|
||||||
android:textColor="@color/half_black" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textViewP2_info_icon_blacklist_p2"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="5dp"
|
|
||||||
android:layout_marginTop="20dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="@string/info_icon_blacklist_p2"
|
|
||||||
android:textColor="@color/half_black" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textViewP3_info_icon_blacklist_p3"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="5dp"
|
|
||||||
android:layout_marginTop="20dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="@string/info_icon_blacklist_p3"
|
|
||||||
android:textColor="@color/half_black" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
@ -1,77 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:background="@drawable/layout_bg"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:padding="10dp"
|
|
||||||
android:textColor="@color/half_black">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textViewP1"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="20dp"
|
|
||||||
android:layout_marginTop="20dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="@string/map_info_text_p1"
|
|
||||||
android:textColor="@color/half_black" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textViewP2"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="20dp"
|
|
||||||
android:layout_marginTop="20dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="@string/map_info_text_p2"
|
|
||||||
android:textColor="@color/half_black" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textViewP3"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="20dp"
|
|
||||||
android:layout_marginTop="20dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="@string/map_info_text_p3"
|
|
||||||
android:textColor="@color/half_black" />
|
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/exactMarkerTextView"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="5dp"
|
|
||||||
android:drawableLeft="@drawable/exact_localization_marker"
|
|
||||||
android:drawablePadding="5dp"
|
|
||||||
android:layout_marginBottom="5dp"
|
|
||||||
android:gravity="center"
|
|
||||||
android:text="@string/map_info_text_marker_exact"
|
|
||||||
android:textColor="@color/half_black" />
|
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/approximateTextView"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="5dp"
|
|
||||||
android:drawableLeft="@drawable/approximate_localization_marker"
|
|
||||||
android:drawablePadding="5dp"
|
|
||||||
android:layout_marginBottom="5dp"
|
|
||||||
android:gravity="center"
|
|
||||||
android:text="@string/map_info_text_marker_approximated"
|
|
||||||
android:textColor="@color/half_black" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/manualMarkerTextView"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="5dp"
|
|
||||||
android:layout_marginBottom="5dp"
|
|
||||||
android:drawableLeft="@drawable/manual_localization_marker"
|
|
||||||
android:drawablePadding="0dp"
|
|
||||||
android:gravity="center"
|
|
||||||
android:text="@string/map_info_text_marker_manual"
|
|
||||||
android:textColor="@color/half_black" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
@ -1,108 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:background="@drawable/layout_bg"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:padding="10dp">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textViewP1"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="5dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="@string/info_icon_sharing_tab_p1"
|
|
||||||
android:textColor="@color/half_black" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textViewP2"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="5dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="@string/info_icon_sharing_tab_p2"
|
|
||||||
android:textColor="@color/half_black"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textViewP3"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="5dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="@string/info_icon_sharing_tab_p3"
|
|
||||||
android:textColor="@color/half_black"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textViewP3exactlvl"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="5dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="@string/info_icon_sharing_tab_p3_level_exact"
|
|
||||||
android:textColor="@color/half_black"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textViewP3approximatelvl"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="5dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="@string/info_icon_sharing_tab_p3_level_approximate"
|
|
||||||
android:textColor="@color/half_black"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textViewP3manuallvl"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="5dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="@string/info_icon_sharing_tab_p3_level_manual"
|
|
||||||
android:textColor="@color/half_black"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textViewP3presencelvl"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="5dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="@string/info_icon_sharing_tab_p3_level_presence"
|
|
||||||
android:textColor="@color/half_black"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textViewP4"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="5dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="@string/info_icon_sharing_tab_p4"
|
|
||||||
android:textColor="@color/half_black"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textViewP5"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="5dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="@string/info_icon_sharing_tab_p5"
|
|
||||||
android:textColor="@color/half_black"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textViewP6"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="5dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="@string/info_icon_sharing_tab_p6"
|
|
||||||
android:textColor="@color/half_black"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textViewP7"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="5dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="@string/info_icon_sharing_tab_p7"
|
|
||||||
android:textColor="@color/half_black"/>
|
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
@ -1,49 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:background="@drawable/layout_bg"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:padding="10dp">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textViewP1"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="5dp"
|
|
||||||
android:layout_marginTop="15dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="@string/info_icon_tutor_tab_p1"
|
|
||||||
android:textColor="@color/half_black"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textViewP2"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="5dp"
|
|
||||||
android:layout_marginTop="15dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="@string/info_icon_tutor_tab_p2"
|
|
||||||
android:textColor="@color/half_black"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textViewP3"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="5dp"
|
|
||||||
android:layout_marginTop="15dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="@string/info_icon_tutor_tab_p3"
|
|
||||||
android:textColor="@color/half_black"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textViewP4"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="5dp"
|
|
||||||
android:layout_marginTop="15dp"
|
|
||||||
android:layout_marginBottom="15dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="@string/info_icon_tutor_tab_p4"
|
|
||||||
android:textColor="@color/half_black"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
@ -1,77 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:padding="20dp"
|
|
||||||
android:background="@drawable/layout_bg">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/userListPopupInfoTextViewP1"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="@string/info_icon_userlist_tab_p1"
|
|
||||||
android:textColor="@color/half_black"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/userListPopupInfoTextViewP2"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="@string/info_icon_userlist_tab_p2"
|
|
||||||
android:textColor="@color/half_black"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/userListPopupInfoTextViewOnline"
|
|
||||||
android:gravity="center"
|
|
||||||
android:drawableLeft="@drawable/online_user"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:drawablePadding="5dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="@string/info_icon_userlist_tab_level_status_online"
|
|
||||||
android:textColor="@color/half_black"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/userListPopupInfoTextVieOffline"
|
|
||||||
android:gravity="center"
|
|
||||||
android:drawableLeft="@drawable/user_list_offline"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:drawablePadding="5dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="@string/info_icon_userlist_tab_level_status_offline"
|
|
||||||
android:textColor="@color/half_black"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/userListPopupInfoTextViewInactive"
|
|
||||||
android:gravity="center"
|
|
||||||
android:drawableLeft="@drawable/user_list_off"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:drawablePadding="5dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="@string/info_icon_userlist_tab_level_status_inactive"
|
|
||||||
android:textColor="@color/half_black"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/userListPopupInfoTextViewTip"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="@string/info_icon_userlist_tab_level_status_inactive_tip"
|
|
||||||
android:textColor="@color/half_black"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/userListPopupInfoTextViewSummary"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_marginTop="10dp"
|
|
||||||
android:text="@string/info_icon_userlist_summary"
|
|
||||||
android:textColor="@color/half_black"/>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
@ -1,39 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:background="@drawable/layout_bg"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:padding="10dp"
|
|
||||||
android:textColor="@color/half_black">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textViewP1_info_icon_whitelist_p1"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="5dp"
|
|
||||||
android:layout_marginTop="5dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="@string/info_icon_whitelist_p1"
|
|
||||||
android:textColor="@color/half_black" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textViewP2_info_icon_whitelist_p2"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="5dp"
|
|
||||||
android:layout_marginTop="20dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="@string/info_icon_whitelist_p2"
|
|
||||||
android:textColor="@color/half_black" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textViewP3_info_icon_whitelist_p3"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="5dp"
|
|
||||||
android:layout_marginTop="20dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="@string/info_icon_whitelist_p3"
|
|
||||||
android:textColor="@color/half_black" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
@ -24,14 +24,14 @@
|
|||||||
android:textStyle="normal" />
|
android:textStyle="normal" />
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/manual_input"
|
android:id="@+id/feedback_input"
|
||||||
android:layout_width="315dp"
|
android:layout_width="315dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
android:layout_marginTop="50dp"
|
android:layout_marginTop="50dp"
|
||||||
android:ems="10"
|
android:ems="10"
|
||||||
android:hint="@string/modal_manual_hint"
|
android:hint="@string/modal_feedback_hint"
|
||||||
android:maxLength="30"
|
android:maxLength="30"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:requiresFadingEdge="vertical"
|
android:requiresFadingEdge="vertical"
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
<PreferenceCategory android:title="@string/settings_category_general">
|
<PreferenceCategory android:title="@string/settings_category_general">
|
||||||
|
|
||||||
<ListPreference
|
<ListPreference
|
||||||
|
android:defaultValue="0"
|
||||||
android:dialogTitle="@string/settings_language"
|
android:dialogTitle="@string/settings_language"
|
||||||
android:entries="@array/language_entries"
|
android:entries="@array/language_entries"
|
||||||
android:entryValues="@array/language_values"
|
android:entryValues="@array/language_values"
|
||||||
@ -14,12 +15,5 @@
|
|||||||
android:summary="%s"
|
android:summary="%s"
|
||||||
android:title="@string/title_language" />
|
android:title="@string/title_language" />
|
||||||
|
|
||||||
<SwitchPreference
|
|
||||||
android:key="acra.enable"
|
|
||||||
android:title="@string/pref_title_acra"
|
|
||||||
android:summaryOn="@string/pref_acra_disabled"
|
|
||||||
android:summaryOff="@string/pref_acra_enabled"
|
|
||||||
android:defaultValue="true"/>
|
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
@ -1,22 +1,23 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
<PreferenceScreen xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/pref_screen"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
tools:ignore="MissingDefaultResource"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:fontFamily="@font/lato_regular"
|
||||||
android:fontFamily="@font/lato_regular">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="category_sharing"
|
android:title="@string/settings_category_location"
|
||||||
android:title="@string/settings_category_location">
|
android:key="category_sharing">
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:disableDependentsState="false"
|
android:disableDependentsState="false"
|
||||||
android:key="key_sharing_enabled"
|
android:key="key_sharing_enabled"
|
||||||
android:persistent="true"
|
android:persistent="true"
|
||||||
android:title="@string/title_sharing" />
|
android:title="@string/title_sharing"/>
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:defaultValue="2"
|
android:defaultValue="1"
|
||||||
android:dialogTitle="@string/settings_location_level"
|
android:dialogTitle="@string/settings_location_level"
|
||||||
android:entries="@array/location_level_entries"
|
android:entries="@array/location_level_entries"
|
||||||
android:entryValues="@array/location_level_values"
|
android:entryValues="@array/location_level_values"
|
||||||
@ -24,44 +25,38 @@
|
|||||||
android:summary="%s"
|
android:summary="%s"
|
||||||
android:title="@string/title_location_level" />
|
android:title="@string/title_location_level" />
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:defaultValue="0"
|
android:key="key_manual_location_value"
|
||||||
android:entries="@array/manual_location_entries"
|
android:entries="@array/manual_location_entries"
|
||||||
android:entryValues="@array/manual_location_values"
|
android:entryValues="@array/manual_location_values"
|
||||||
android:key="key_manual_location_value"
|
|
||||||
android:summary="%s"
|
android:summary="%s"
|
||||||
android:title="@string/title_list_manual_location" />
|
android:title="@string/title_list_manual_location" />
|
||||||
<com.uam.wmi.findmytutor.utils.RightButtonPreference
|
<com.uam.wmi.findmytutor.utils.RightButtonPreference
|
||||||
android:key="manual_location_button"
|
android:key="manual_location_button"
|
||||||
android:text="@string/preference_manual_location_button" />
|
/>
|
||||||
<com.uam.wmi.findmytutor.utils.RightButtonPreference
|
|
||||||
android:key="remove_manual_location"
|
|
||||||
android:text="@string/preference_manual_location_button_remove" />
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory android:title="@string/settings_category_status">
|
<PreferenceCategory android:title="@string/settings_category_status">
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:disableDependentsState="false"
|
android:disableDependentsState="false"
|
||||||
android:key="key_status_enabled"
|
android:key="key_status_enabled"
|
||||||
android:persistent="true"
|
android:persistent="true"
|
||||||
android:title="@string/status_switch_title" />
|
android:title="@string/status_switch_title"/>
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:defaultValue="0"
|
android:defaultValue="1"
|
||||||
|
android:key="@string/key_status_value"
|
||||||
android:entries="@array/status_entries"
|
android:entries="@array/status_entries"
|
||||||
android:entryValues="@array/status_values"
|
android:entryValues="@array/status_values"
|
||||||
android:key="@string/key_status_value"
|
|
||||||
android:summary="%s"
|
android:summary="%s"
|
||||||
android:title="@string/status_list_title" />
|
android:title="@string/status_list_title" />
|
||||||
<EditTextPreference
|
<EditTextPreference
|
||||||
android:key="key_manual_status"
|
android:key="key_manual_status"
|
||||||
android:selectAllOnFocus="true"
|
android:selectAllOnFocus="true"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:title="@string/title_manual_status" />
|
android:title="@string/title_manual_status"
|
||||||
<com.uam.wmi.findmytutor.utils.RightButtonPreference
|
/>
|
||||||
android:key="remove_manual_status"
|
|
||||||
android:textColor="@color/white"
|
|
||||||
app:backgroundTint="@color/mapboxRedDark"
|
|
||||||
android:text="@string/preference_manual_status_button_remove" />
|
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
@ -1,23 +1,13 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:gravity="right"
|
android:gravity="right"
|
||||||
android:fontFamily="@font/lato_regular"
|
|
||||||
>
|
>
|
||||||
|
<Button xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
<android.support.v7.widget.AppCompatButton
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:id="@+id/button_choose_from_map"
|
android:id="@+id/button_choose_from_map"
|
||||||
android:text="@string/preference_manual_location_button"
|
android:text="@string/preference_manual_location_button"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:textColor="@color/white"
|
|
||||||
app:backgroundTint="@color/top_user_modal"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:stateListAnimator="@null"
|
|
||||||
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:gravity="right"
|
|
||||||
xmlns:mapbox="http://schemas.android.com/apk/res-auto">
|
|
||||||
|
|
||||||
<ImageButton
|
|
||||||
android:id="@+id/sharingTabInfoImageButton"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="info"
|
|
||||||
mapbox:srcCompat="@drawable/outline_info_24"/>
|
|
||||||
</LinearLayout>
|
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="90dp"
|
android:layout_height="90dp"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
@ -13,48 +13,36 @@
|
|||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/firstName"
|
android:id="@+id/firstName"
|
||||||
android:layout_width="270dp"
|
android:layout_width="271dp"
|
||||||
android:layout_height="22dp"
|
android:layout_height="22dp"
|
||||||
android:layout_alignParentStart="true"
|
android:layout_alignParentStart="true"
|
||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
android:layout_marginStart="12dp"
|
android:layout_marginStart="12dp"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
|
|
||||||
android:textColor="@color/note_list_text"
|
android:textColor="@color/note_list_text"
|
||||||
android:textSize="15sp" />
|
android:textSize="15sp" />
|
||||||
|
|
||||||
|
|
||||||
<com.github.ybq.android.spinkit.SpinKitView xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:id="@+id/loader"
|
|
||||||
style="@style/SpinKitView.Large.Wave"
|
|
||||||
android:layout_marginStart="12dp"
|
|
||||||
android:layout_marginTop="35dp"
|
|
||||||
android:layout_width="30dp"
|
|
||||||
android:layout_height="30dp"
|
|
||||||
app:SpinKit_Color="@color/colorAccent" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/lastSeen"
|
android:id="@+id/lastName"
|
||||||
android:layout_width="270dp"
|
android:layout_width="270dp"
|
||||||
android:layout_height="22dp"
|
android:layout_height="22dp"
|
||||||
android:layout_marginStart="12dp"
|
|
||||||
android:layout_below="@+id/firstName"
|
android:layout_below="@+id/firstName"
|
||||||
android:layout_alignEnd="@+id/firstName"
|
android:layout_alignEnd="@+id/firstName"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
android:layout_marginEnd="0dp"
|
android:layout_marginEnd="0dp"
|
||||||
android:layout_alignParentStart="true"
|
android:textColor="@color/note_list_text"
|
||||||
android:textColor="#979797"
|
android:textSize="15sp" />
|
||||||
android:textSize="13sp" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/isOnline"
|
android:id="@+id/isOnline"
|
||||||
android:layout_width="50dp"
|
android:layout_width="48dp"
|
||||||
android:layout_height="30dp"
|
android:layout_height="30dp"
|
||||||
android:layout_below="@+id/firstName"
|
android:layout_below="@+id/firstName"
|
||||||
android:layout_marginStart="7dp"
|
android:layout_marginStart="7dp"
|
||||||
android:layout_marginTop="-10dp"
|
android:layout_marginTop="-10dp"
|
||||||
|
android:layout_toEndOf="@+id/firstName"
|
||||||
android:textColor="@color/note_list_text"
|
android:textColor="@color/note_list_text"
|
||||||
android:layout_alignParentEnd="true"
|
|
||||||
android:textSize="@dimen/note_list_text" />
|
android:textSize="@dimen/note_list_text" />
|
||||||
|
|
||||||
|
|
||||||
|