Merge branch 'users-list-last-seen' of s416084/find-my-tutor-android into develop
This commit is contained in:
commit
f872b08acc
@ -10,10 +10,11 @@ android {
|
|||||||
applicationId "com.uam.wmi.findmytutor"
|
applicationId "com.uam.wmi.findmytutor"
|
||||||
minSdkVersion 22
|
minSdkVersion 22
|
||||||
targetSdkVersion 27
|
targetSdkVersion 27
|
||||||
versionCode 55
|
versionCode 56
|
||||||
versionName "1.0.0"
|
versionName "1.0.0"
|
||||||
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 {
|
||||||
@ -37,10 +38,8 @@ dependencies {
|
|||||||
implementation "ch.acra:acra-limiter:$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'
|
||||||
@ -72,6 +71,10 @@ dependencies {
|
|||||||
// 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:appcompat-v7:27.1.1'
|
|
||||||
implementation 'com.android.support:design:27.1.1'
|
implementation 'com.android.support:design:27.1.1'
|
||||||
|
|
||||||
|
// spinner loaders library
|
||||||
|
implementation 'com.github.ybq:Android-SpinKit:1.2.0'
|
||||||
|
implementation 'com.akexorcist:localizationactivity:1.2.2'
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
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"
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
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;
|
||||||
@ -13,6 +14,8 @@ 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.
|
||||||
@ -21,6 +24,11 @@ public abstract class AppCompatPreferenceActivity extends PreferenceActivity {
|
|||||||
|
|
||||||
private AppCompatDelegate mDelegate;
|
private AppCompatDelegate mDelegate;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void attachBaseContext(Context base) {
|
||||||
|
super.attachBaseContext(LocaleHelper.onAttach(base));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
getDelegate().installViewFactory();
|
getDelegate().installViewFactory();
|
||||||
|
@ -4,6 +4,7 @@ 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;
|
||||||
@ -35,6 +36,8 @@ 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.PrefUtils;
|
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||||
import com.uam.wmi.findmytutor.utils.RxSearchObservable;
|
import com.uam.wmi.findmytutor.utils.RxSearchObservable;
|
||||||
|
|
||||||
@ -85,6 +88,11 @@ public abstract class BaseActivity
|
|||||||
public SearchView searchView;
|
public SearchView searchView;
|
||||||
public MenuItem infoMenuItem;
|
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) {
|
||||||
@ -436,4 +444,8 @@ public abstract class BaseActivity
|
|||||||
|
|
||||||
abstract int getNavigationMenuItemId();
|
abstract int getNavigationMenuItemId();
|
||||||
abstract int getContentViewId();
|
abstract int getContentViewId();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
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.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.design.widget.CoordinatorLayout;
|
import android.support.design.widget.CoordinatorLayout;
|
||||||
@ -31,6 +32,7 @@ import android.widget.TextView;
|
|||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import android.widget.ToggleButton;
|
import android.widget.ToggleButton;
|
||||||
|
|
||||||
|
import com.github.ybq.android.spinkit.SpinKitView;
|
||||||
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
|
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
|
||||||
import com.mapbox.geojson.Point;
|
import com.mapbox.geojson.Point;
|
||||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||||
@ -44,6 +46,7 @@ import com.uam.wmi.findmytutor.model.UserResponseModel;
|
|||||||
import com.uam.wmi.findmytutor.network.ApiClient;
|
import com.uam.wmi.findmytutor.network.ApiClient;
|
||||||
import com.uam.wmi.findmytutor.service.PredefinedStatusesService;
|
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.LocaleHelper;
|
||||||
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.PrefUtils;
|
||||||
import com.uam.wmi.findmytutor.utils.RecyclerTouchListener;
|
import com.uam.wmi.findmytutor.utils.RecyclerTouchListener;
|
||||||
@ -86,12 +89,20 @@ public class BlackList extends AppCompatActivity {
|
|||||||
Switch aSwitch;
|
Switch aSwitch;
|
||||||
@BindView(R.id.add_to_black_list_fab)
|
@BindView(R.id.add_to_black_list_fab)
|
||||||
FloatingActionButton addToBlackListFab;
|
FloatingActionButton addToBlackListFab;
|
||||||
|
@BindView(R.id.loader)
|
||||||
|
SpinKitView loader;
|
||||||
|
|
||||||
|
|
||||||
private Integer prevSize;
|
private Integer prevSize;
|
||||||
private BlackListAdapter mAdapter;
|
private BlackListAdapter mAdapter;
|
||||||
private List<User> blacklistedUsers = new ArrayList<>();
|
private List<User> blacklistedUsers = new ArrayList<>();
|
||||||
private Collator plCollator = Collator.getInstance(Locale.forLanguageTag("pl-PL"));
|
private Collator plCollator = Collator.getInstance(Locale.forLanguageTag("pl-PL"));
|
||||||
|
|
||||||
|
@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);
|
||||||
@ -122,6 +133,7 @@ public class BlackList extends AppCompatActivity {
|
|||||||
recyclerView.setItemAnimator(new DefaultItemAnimator());
|
recyclerView.setItemAnimator(new DefaultItemAnimator());
|
||||||
recyclerView.addItemDecoration(new MyDividerItemDecoration(this, LinearLayoutManager.VERTICAL, 16));
|
recyclerView.addItemDecoration(new MyDividerItemDecoration(this, LinearLayoutManager.VERTICAL, 16));
|
||||||
recyclerView.setAdapter(mAdapter);
|
recyclerView.setAdapter(mAdapter);
|
||||||
|
noNotesView.setVisibility(View.GONE);
|
||||||
|
|
||||||
fetchBlackListedUsers();
|
fetchBlackListedUsers();
|
||||||
/**
|
/**
|
||||||
@ -275,15 +287,15 @@ public class BlackList extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void toggleEmptyNotes() {
|
private void toggleEmptyNotes() {
|
||||||
|
|
||||||
if (didFetched && blacklistedUsers.size() == 0) {
|
if (didFetched && blacklistedUsers.size() == 0) {
|
||||||
noNotesView.setText(R.string.list_is_empty);
|
|
||||||
noNotesView.setVisibility(View.VISIBLE);
|
noNotesView.setVisibility(View.VISIBLE);
|
||||||
|
noNotesView.setText(R.string.list_is_empty);
|
||||||
|
loader.setVisibility(View.GONE);
|
||||||
}else if (blacklistedUsers.size() > 0) {
|
}else if (blacklistedUsers.size() > 0) {
|
||||||
noNotesView.setVisibility(View.GONE);
|
noNotesView.setVisibility(View.GONE);
|
||||||
|
loader.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
noNotesView.setText(getString(R.string.loading));
|
loader.setVisibility(View.VISIBLE);
|
||||||
noNotesView.setVisibility(View.VISIBLE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package com.uam.wmi.findmytutor.activity;
|
|||||||
import android.animation.Animator;
|
import android.animation.Animator;
|
||||||
import android.animation.AnimatorListenerAdapter;
|
import android.animation.AnimatorListenerAdapter;
|
||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
@ -27,6 +28,7 @@ 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.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;
|
||||||
|
|
||||||
@ -50,6 +52,11 @@ LoginActivity extends AppCompatActivity {
|
|||||||
private UserService userService;
|
private UserService userService;
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
|
@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);
|
||||||
|
@ -4,6 +4,7 @@ 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;
|
||||||
@ -48,6 +49,7 @@ import com.uam.wmi.findmytutor.service.PredefinedCoordinatesService;
|
|||||||
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.EnableSharingDialog;
|
||||||
|
import com.uam.wmi.findmytutor.utils.LocaleHelper;
|
||||||
import com.uam.wmi.findmytutor.utils.LocaleUtils;
|
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;
|
||||||
@ -103,6 +105,11 @@ 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);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
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;
|
||||||
@ -15,12 +16,15 @@ 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();
|
||||||
|
|
||||||
@ -33,9 +37,15 @@ 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;
|
||||||
@ -62,9 +72,12 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||||||
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");
|
||||||
}
|
}
|
||||||
|
@ -3,41 +3,36 @@ package com.uam.wmi.findmytutor.activity;
|
|||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.FragmentTransaction;
|
import android.app.FragmentTransaction;
|
||||||
import android.app.TimePickerDialog;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
|
||||||
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.preference.SwitchPreference;
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TimePicker;
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.annimon.stream.IntPair;
|
import com.annimon.stream.IntPair;
|
||||||
import com.annimon.stream.Stream;
|
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.TutorsListAdapter;
|
|
||||||
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.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.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 org.apache.commons.collections4.BidiMap;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -49,6 +44,7 @@ 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 static com.mapbox.mapboxsdk.Mapbox.getApplicationContext;
|
import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext;
|
||||||
|
|
||||||
|
|
||||||
@ -63,9 +59,9 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
|||||||
protected RightButtonPreference removeManualStatus;
|
protected RightButtonPreference removeManualStatus;
|
||||||
protected Preference manualStatus;
|
protected Preference manualStatus;
|
||||||
protected ListPreference statusList;
|
protected ListPreference statusList;
|
||||||
private HashMap<String,String> locationMap;
|
|
||||||
private ArrayList <String> locationUUIDs;
|
|
||||||
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;
|
||||||
@ -74,9 +70,9 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
|||||||
private AlertDialog.Builder builder;
|
private AlertDialog.Builder builder;
|
||||||
private String[] statusesArray;
|
private String[] statusesArray;
|
||||||
private boolean statusSwitchFlag;
|
private boolean statusSwitchFlag;
|
||||||
private ArrayList<String> predefinedLocationsList;
|
private ArrayList<String> predefinedLocationsList;
|
||||||
|
|
||||||
public static SharingFragment newInstance() {
|
public static SharingFragment newInstance() {
|
||||||
return new SharingFragment();
|
return new SharingFragment();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,12 +84,12 @@ 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()]);
|
statusesArray = strings.toArray(new String[strings.size()]);
|
||||||
if(strings.isEmpty()){
|
if (strings.isEmpty()) {
|
||||||
disableStatusPreferences();
|
disableStatusPreferences();
|
||||||
}else{
|
} else {
|
||||||
enableStatusPreferences();
|
enableStatusPreferences();
|
||||||
}
|
}
|
||||||
// Log.d("STATUSES",Integer.toString(statusesArray.length ));
|
// Log.d("STATUSES",Integer.toString(statusesArray.length ));
|
||||||
setListPreferenceData(statusList, statusesArray, null);
|
setListPreferenceData(statusList, statusesArray, null);
|
||||||
}
|
}
|
||||||
@ -116,35 +112,36 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
|||||||
public void onSuccess(List<PredefinedCoordViewModel> coords) {
|
public void onSuccess(List<PredefinedCoordViewModel> coords) {
|
||||||
|
|
||||||
String currentCoordId = PrefUtils.getCurrentManualLocation(getApplicationContext());
|
String currentCoordId = PrefUtils.getCurrentManualLocation(getApplicationContext());
|
||||||
locationMap = new HashMap<String,String>();
|
locationMap = new HashMap<String, String>();
|
||||||
locationUUIDs = new ArrayList<String>();
|
locationUUIDs = new ArrayList<String>();
|
||||||
for (PredefinedCoordViewModel i : coords) locationMap.put(i.getPredefinedCoordinateId(),i.getName());
|
for (PredefinedCoordViewModel i : coords)
|
||||||
for (PredefinedCoordViewModel i : coords) locationUUIDs.add(i.getPredefinedCoordinateId());
|
locationMap.put(i.getPredefinedCoordinateId(), i.getName());
|
||||||
List<String> predefinedLocationsNames = Stream.of(coords).map(PredefinedCoordViewModel::getName).toList();
|
for (PredefinedCoordViewModel i : coords)
|
||||||
List<String> predefinedLocationsUUIDs = Stream.of(coords).map(PredefinedCoordViewModel::getPredefinedCoordinateId).toList();
|
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")) {
|
if (!PrefUtils.getLocationLevel(getApplicationContext()).equals("manual")) {
|
||||||
preferenceCategory.removePreference(manualLocationList);
|
preferenceCategory.removePreference(manualLocationList);
|
||||||
preferenceCategory.removePreference(removeManualLocation);
|
preferenceCategory.removePreference(removeManualLocation);
|
||||||
preferenceCategory.removePreference(manualLocationButton);
|
preferenceCategory.removePreference(manualLocationButton);
|
||||||
}else{
|
} else {
|
||||||
if(!predefinedCoordsList.isEmpty()){
|
if (!predefinedCoordsList.isEmpty()) {
|
||||||
|
|
||||||
manualLocationList.setEnabled(true);
|
manualLocationList.setEnabled(true);
|
||||||
manualLocationList.setSummary(PrefUtils.getCurrentManualLocationName(getApplicationContext()));
|
manualLocationList.setSummary(PrefUtils.getCurrentManualLocationName(getApplicationContext()));
|
||||||
removeManualLocation.setEnabled(true);
|
removeManualLocation.setEnabled(true);
|
||||||
locationSharing.setEnabled(true);
|
locationSharing.setEnabled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String[] stringnames = predefinedLocationsNames.toArray(new String[0]);
|
String[] stringnames = predefinedLocationsNames.toArray(new String[0]);
|
||||||
predefinedLocationsList = new ArrayList<>(Arrays.asList(stringnames));
|
predefinedLocationsList = new ArrayList<>(Arrays.asList(stringnames));
|
||||||
List<Integer> activesId = Stream.of(coords).indexed()
|
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 (activesId.size() == 0) {
|
||||||
setListPreferenceData(manualLocationList, stringnames, null);
|
setListPreferenceData(manualLocationList, stringnames, null);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
setListPreferenceData(manualLocationList, stringnames, activesId.get(0));
|
setListPreferenceData(manualLocationList, stringnames, activesId.get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,11 +172,11 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
|||||||
removeManualStatus = (RightButtonPreference) findPreference("remove_manual_status");
|
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);
|
locationService = ApiClient.getClient(getApplicationContext()).create(PredefinedCoordinatesService.class);
|
||||||
disposable = new CompositeDisposable();
|
disposable = new CompositeDisposable();
|
||||||
statusesArray = new String[0];
|
statusesArray = new String[0];
|
||||||
predefinedLocationsList = new ArrayList<String>();
|
predefinedLocationsList = new ArrayList<String>();
|
||||||
getStatuses(disposable);
|
getStatuses(disposable);
|
||||||
getLocations(disposable);
|
getLocations(disposable);
|
||||||
locationLevelMapping = new HashMap<Integer, String>();
|
locationLevelMapping = new HashMap<Integer, String>();
|
||||||
@ -197,7 +194,6 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
|||||||
manualLocationList.setSummary(PrefUtils.getCurrentManualLocationName(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);
|
||||||
@ -209,19 +205,19 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
|||||||
locationMode.setOnPreferenceChangeListener((preference, newValue) -> {
|
locationMode.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||||
((MapActivity) getActivity()).stopBackgroundLocalizationTask();
|
((MapActivity) getActivity()).stopBackgroundLocalizationTask();
|
||||||
((MapActivity) getActivity()).startBackgroundLocalizationTask();
|
((MapActivity) getActivity()).startBackgroundLocalizationTask();
|
||||||
PrefUtils.storeLocationMode(getApplicationContext(), locationLevelMapping.get(Integer.parseInt((String) newValue)));
|
PrefUtils.storeLocationMode(getApplicationContext(), locationLevelMapping.get(Integer.parseInt((String) newValue)));
|
||||||
|
|
||||||
if (PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.MANUAL.toString())) {
|
if (PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.MANUAL.toString())) {
|
||||||
if (!predefinedCoordsList.isEmpty()) {
|
if (!predefinedCoordsList.isEmpty()) {
|
||||||
preferenceCategory.addPreference(manualLocationList);
|
preferenceCategory.addPreference(manualLocationList);
|
||||||
preferenceCategory.addPreference(removeManualLocation);
|
preferenceCategory.addPreference(removeManualLocation);
|
||||||
}
|
}
|
||||||
preferenceCategory.addPreference(manualLocationButton);
|
preferenceCategory.addPreference(manualLocationButton);
|
||||||
} else {
|
} else {
|
||||||
locationSharing.setEnabled(true);
|
locationSharing.setEnabled(true);
|
||||||
preferenceCategory.removePreference(manualLocationList);
|
preferenceCategory.removePreference(manualLocationList);
|
||||||
preferenceCategory.removePreference(manualLocationButton);
|
preferenceCategory.removePreference(manualLocationButton);
|
||||||
preferenceCategory.removePreference(removeManualLocation);
|
preferenceCategory.removePreference(removeManualLocation);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
@ -251,8 +247,6 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** Button 'choose from map' button listener **/
|
/** Button 'choose from map' button listener **/
|
||||||
manualLocationButton.setOnPreferenceChangeListener((preference, o) -> {
|
manualLocationButton.setOnPreferenceChangeListener((preference, o) -> {
|
||||||
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
|
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
|
||||||
@ -270,17 +264,16 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
|||||||
lp.setSummary(entries[Integer.parseInt((String) newValue)]);
|
lp.setSummary(entries[Integer.parseInt((String) newValue)]);
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
statusList.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
statusList.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
|
|
||||||
if(statusesArray.length == 0)
|
if (statusesArray.length == 0) {
|
||||||
{
|
builder.setTitle("nie ma wody na pustyni");
|
||||||
builder.setTitle("nie ma wody na pustyni");
|
}
|
||||||
}
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
/** Custom status edittext change listener **/
|
/** Custom status edittext change listener **/
|
||||||
manualStatus.setOnPreferenceChangeListener((preference, newValue) -> {
|
manualStatus.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||||
|
|
||||||
@ -291,39 +284,40 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
removeManualStatus.setOnPreferenceChangeListener((preference, newValue) -> {
|
removeManualStatus.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||||
showRemoveDialog(statusList.getEntries(),"status");
|
showRemoveDialog(statusList.getEntries(), "status");
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
removeManualLocation.setOnPreferenceChangeListener(((preference, newValue) -> {
|
removeManualLocation.setOnPreferenceChangeListener(((preference, newValue) -> {
|
||||||
showRemoveDialog(manualLocationList.getEntries(),"location");
|
showRemoveDialog(manualLocationList.getEntries(), "location");
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
public void showRemoveDialog(CharSequence[] entries, String service){
|
|
||||||
boolean [] checked = new boolean[entries.length];
|
public void showRemoveDialog(CharSequence[] entries, String service) {
|
||||||
|
boolean[] checked = new boolean[entries.length];
|
||||||
ArrayList<String> tobeDeleted = new ArrayList<String>();
|
ArrayList<String> tobeDeleted = new ArrayList<String>();
|
||||||
// Log.d("sharingDialog", "no to siup");
|
// Log.d("sharingDialog", "no to siup");
|
||||||
builder.setPositiveButton("DELETE", new DialogInterface.OnClickListener() {
|
builder.setPositiveButton("DELETE", new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
for (int i=0; i< entries.length; i++){
|
for (int i = 0; i < entries.length; i++) {
|
||||||
if(checked[i] == true) {
|
if (checked[i] == true) {
|
||||||
tobeDeleted.add((String) entries[i]);
|
tobeDeleted.add((String) entries[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
removeEntries(service,tobeDeleted);
|
removeEntries(service, tobeDeleted);
|
||||||
// Log.d("MANAGE-PREF",tobeDeleted.toString());
|
// Log.d("MANAGE-PREF",tobeDeleted.toString());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setMultiChoiceItems(entries, checked, new DialogInterface.OnMultiChoiceClickListener() {
|
builder.setMultiChoiceItems(entries, checked, new DialogInterface.OnMultiChoiceClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
|
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.create().show();
|
builder.create().show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -335,34 +329,34 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
|||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void removeEntries(String service, ArrayList<String> toBeDeleted){
|
protected void removeEntries(String service, ArrayList<String> toBeDeleted) {
|
||||||
|
|
||||||
// Log.d("MANAGE-PREF", toBeDeleted.toString());
|
// Log.d("MANAGE-PREF", toBeDeleted.toString());
|
||||||
if(service.equals("status")){
|
if (service.equals("status")) {
|
||||||
for (String uuid:toBeDeleted) {
|
for (String uuid : toBeDeleted) {
|
||||||
disposable.add(statusesService.deleteUserPredefinedStatus(PrefUtils.getUserId(getApplicationContext()), uuid)
|
disposable.add(statusesService.deleteUserPredefinedStatus(PrefUtils.getUserId(getApplicationContext()), uuid)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(this::handleDeleteStatuses, this::handleError));
|
.subscribe(this::handleDeleteStatuses, this::handleError));
|
||||||
}
|
}
|
||||||
}else {
|
} else {
|
||||||
ArrayList<String> uuidsToBeDeleted = new ArrayList<String>();
|
ArrayList<String> uuidsToBeDeleted = new ArrayList<String>();
|
||||||
for (String name:toBeDeleted) {
|
for (String name : toBeDeleted) {
|
||||||
for (String uuid:locationUUIDs) {
|
for (String uuid : locationUUIDs) {
|
||||||
if(locationMap.get(uuid).equals(name)){
|
if (locationMap.get(uuid).equals(name)) {
|
||||||
uuidsToBeDeleted.add(uuid);
|
uuidsToBeDeleted.add(uuid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
for (String uuid : uuidsToBeDeleted) {
|
||||||
for (String uuid : uuidsToBeDeleted) {
|
|
||||||
// predefinedCoordsList.removeIf(x -> x.getPredefinedCoordinateId().equals(uuid));
|
// predefinedCoordsList.removeIf(x -> x.getPredefinedCoordinateId().equals(uuid));
|
||||||
predefinedCoordsList.removeAll(Stream.of(predefinedCoordsList).filter(x -> x.getPredefinedCoordinateId().equals(uuid)).toList());
|
predefinedCoordsList.removeAll(Stream.of(predefinedCoordsList).filter(x -> x.getPredefinedCoordinateId().equals(uuid)).toList());
|
||||||
disposable.add(locationService.deleteUserPredefinedCoord(PrefUtils.getUserId(getApplicationContext()), uuid)
|
disposable.add(locationService.deleteUserPredefinedCoord(PrefUtils.getUserId(getApplicationContext()), uuid)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(this::handleDeleteLocations, this::handleError));
|
.subscribe(this::handleDeleteLocations, this::handleError));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setListPreferenceData(ListPreference lp, String[] entries, Integer activeId) {
|
protected void setListPreferenceData(ListPreference lp, String[] entries, Integer activeId) {
|
||||||
@ -390,13 +384,13 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
|||||||
;
|
;
|
||||||
|
|
||||||
private void handleResponse(List<String> resp) {
|
private void handleResponse(List<String> resp) {
|
||||||
if(resp.size() == 1){
|
if (resp.size() == 1) {
|
||||||
enableStatusPreferences();
|
enableStatusPreferences();
|
||||||
if(PrefUtils.isStatusEnabled(getApplicationContext()) == false){
|
if (PrefUtils.isStatusEnabled(getApplicationContext()) == false) {
|
||||||
PrefUtils.enableStatus(getApplicationContext());
|
PrefUtils.enableStatus(getApplicationContext());
|
||||||
statusSwitch.setChecked(true);
|
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, statusesArray, resp.size() - 1);
|
||||||
statusList.setValueIndex(resp.size() - 1);
|
statusList.setValueIndex(resp.size() - 1);
|
||||||
@ -415,79 +409,84 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
|||||||
"Network error " + error.getMessage(), Toast.LENGTH_SHORT).show();
|
"Network error " + error.getMessage(), Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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 handleDeleteStatuses(List<String> resp) {
|
||||||
private void handleDeleteLocations(List<PredefinedCoordViewModel> resp){
|
if (resp.isEmpty()) {
|
||||||
getLocations(disposable);
|
disableStatusPreferences();
|
||||||
String currentEntry = PrefUtils.getCurrentManualLocation(getApplicationContext());
|
} else {
|
||||||
if(resp.isEmpty()){
|
String[] statusesArray = resp.toArray(new String[resp.size()]);
|
||||||
disableManualLocationPreferences();
|
setListPreferenceData(statusList, statusesArray, null);
|
||||||
}else{
|
String currentEntry = PrefUtils.getUserStatus(getApplicationContext());
|
||||||
if(!Stream.of(resp).filter(x -> x.getName().equals(currentEntry)).toList().isEmpty())
|
if (resp.contains(currentEntry)) {
|
||||||
{
|
statusList.setValueIndex(resp.indexOf(currentEntry));
|
||||||
for (PredefinedCoordViewModel location: resp) {
|
} else {
|
||||||
if(location.getName().equals(currentEntry)){
|
statusList.setValueIndex(0);
|
||||||
manualLocationList.setValueIndex(resp.indexOf(location));
|
statusList.setSummary(resp.get(0));
|
||||||
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 handleDeleteLocations(List<PredefinedCoordViewModel> resp) {
|
||||||
private void enableStatusPreferences(){
|
getLocations(disposable);
|
||||||
removeManualStatus.setEnabled(true);
|
String currentEntry = PrefUtils.getCurrentManualLocation(getApplicationContext());
|
||||||
statusList.setEnabled(true);
|
if (resp.isEmpty()) {
|
||||||
statusSwitch.setEnabled(true);
|
disableManualLocationPreferences();
|
||||||
statusList.setSummary(PrefUtils.getUserStatus(getApplicationContext()));
|
} else {
|
||||||
}
|
if (!Stream.of(resp).filter(x -> x.getName().equals(currentEntry)).toList().isEmpty()) {
|
||||||
private void disableManualLocationPreferences(){
|
for (PredefinedCoordViewModel location : resp) {
|
||||||
removeManualLocation.setEnabled(false);
|
if (location.getName().equals(currentEntry)) {
|
||||||
manualLocationList.setEnabled(false);
|
manualLocationList.setValueIndex(resp.indexOf(location));
|
||||||
manualLocationList.setSummary("");
|
break;
|
||||||
locationSharing.setChecked(false);
|
}
|
||||||
locationSharing.setEnabled(false);
|
}
|
||||||
PrefUtils.disableSharing(getApplicationContext());
|
} else {
|
||||||
((MapActivity) getActivity()).handleBackgroundTaskLifeCycle();
|
manualLocationList.setValueIndex(0);
|
||||||
|
manualLocationList.setSummary(resp.get(0).getName());
|
||||||
}
|
//todo czy na pewno w shared pref sa dobre wartosci
|
||||||
private void enableManualLocationPreferences(){
|
}
|
||||||
removeManualLocation.setEnabled(true);
|
|
||||||
manualLocationList.setEnabled(true);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
|
||||||
locationSharing.setChecked(PrefUtils.isEnableSharingLocalization(getApplicationContext()));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
@ -507,4 +506,5 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
|||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
disposable.dispose();
|
disposable.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.uam.wmi.findmytutor.activity;
|
package com.uam.wmi.findmytutor.activity;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
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;
|
||||||
@ -11,6 +12,7 @@ import android.widget.ScrollView;
|
|||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
|
||||||
|
import com.uam.wmi.findmytutor.utils.LocaleHelper;
|
||||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@ -19,6 +21,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) {
|
||||||
|
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
package com.uam.wmi.findmytutor.activity;
|
package com.uam.wmi.findmytutor.activity;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.design.widget.TextInputEditText;
|
import android.support.design.widget.TextInputEditText;
|
||||||
import android.support.design.widget.TextInputLayout;
|
|
||||||
import android.support.v7.app.AlertDialog;
|
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
@ -29,12 +28,11 @@ 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.InfoHelperUtils;
|
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.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
@ -42,12 +40,10 @@ import java.util.regex.Pattern;
|
|||||||
import butterknife.ButterKnife;
|
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.DisposableCompletableObserver;
|
|
||||||
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;
|
import static java.lang.String.valueOf;
|
||||||
|
|
||||||
public class TutorTab extends AppCompatActivity {
|
public class TutorTab extends AppCompatActivity {
|
||||||
@ -69,6 +65,9 @@ public class TutorTab extends AppCompatActivity {
|
|||||||
private DutyHoursAdapter dutyHoursAdapter;
|
private DutyHoursAdapter dutyHoursAdapter;
|
||||||
private RecyclerView.LayoutManager dutyHoursLayoutManager;
|
private RecyclerView.LayoutManager dutyHoursLayoutManager;
|
||||||
private TutorTabViewModel newTab;
|
private TutorTabViewModel newTab;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public boolean isEmailValid(String email)
|
public boolean isEmailValid(String email)
|
||||||
{
|
{
|
||||||
String regExpn =
|
String regExpn =
|
||||||
@ -94,17 +93,18 @@ public class TutorTab extends AppCompatActivity {
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||||
setContentView(R.layout.content_tutor_tab);
|
setContentView(R.layout.content_tutor_tab);
|
||||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
|
||||||
toolbar.setTitle(getString(R.string.profile_activity_title));
|
|
||||||
setSupportActionBar(toolbar);
|
|
||||||
ButterKnife.bind(this);
|
ButterKnife.bind(this);
|
||||||
|
|
||||||
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||||
|
toolbar.setTitle(R.string.profile_activity_title);
|
||||||
|
setSupportActionBar(toolbar);
|
||||||
|
|
||||||
userName = findViewById(R.id.userName);
|
userName = findViewById(R.id.userName);
|
||||||
userNote = (TextInputEditText) findViewById(R.id.userNote);
|
userNote = findViewById(R.id.userNote);
|
||||||
userRoom = findViewById(R.id.userRoom);
|
userRoom = findViewById(R.id.userRoom);
|
||||||
userEmail = findViewById(R.id.userEmail);
|
userEmail = findViewById(R.id.userEmail);
|
||||||
department = findViewById(R.id.userDepartment);
|
department = findViewById(R.id.userDepartment);
|
||||||
saveButon = findViewById(R.id.saveButon);
|
saveButon = findViewById(R.id.saveButton);
|
||||||
scrapButton = findViewById(R.id.scrapTutorTab);
|
scrapButton = findViewById(R.id.scrapTutorTab);
|
||||||
addDutyButton = findViewById(R.id.addDuty);
|
addDutyButton = findViewById(R.id.addDuty);
|
||||||
dutyHoursRecycller = findViewById(R.id.dutyHourView);
|
dutyHoursRecycller = findViewById(R.id.dutyHourView);
|
||||||
@ -304,4 +304,10 @@ public class TutorTab extends AppCompatActivity {
|
|||||||
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import android.app.Fragment;
|
|||||||
import android.app.FragmentTransaction;
|
import android.app.FragmentTransaction;
|
||||||
import android.graphics.drawable.Drawable;
|
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;
|
||||||
@ -30,6 +31,7 @@ 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;
|
||||||
@ -57,8 +59,12 @@ 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.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;
|
||||||
@ -74,6 +80,8 @@ 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 SearchView searchView;
|
||||||
private UserService userService;
|
private UserService userService;
|
||||||
@ -95,7 +103,6 @@ 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(), tutorsList, tutorsTimeStamps);
|
||||||
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));
|
||||||
@ -119,6 +126,7 @@ public class UsersListFragment extends Fragment {
|
|||||||
recyclerView.setVerticalScrollBarEnabled(true);
|
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();
|
fetchTopCords();
|
||||||
@ -404,9 +412,10 @@ public class UsersListFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void toggleEmptyNotes() {
|
private void toggleEmptyNotes() {
|
||||||
if (tutorsList.size() > 0) {
|
loader.setVisibility(View.GONE);
|
||||||
noNotesView.setVisibility(View.GONE);
|
noNotesView.setVisibility(View.GONE);
|
||||||
} else {
|
|
||||||
|
if (tutorsList.size() == 0) {
|
||||||
noNotesView.setVisibility(View.VISIBLE);
|
noNotesView.setVisibility(View.VISIBLE);
|
||||||
if (fetchOnlyOnlineUsers)
|
if (fetchOnlyOnlineUsers)
|
||||||
noNotesView.setText(R.string.no_online_users);
|
noNotesView.setText(R.string.no_online_users);
|
||||||
@ -442,28 +451,44 @@ public class UsersListFragment extends Fragment {
|
|||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Observable<List<User>> getListOfActiveUsers() {
|
||||||
|
return userService.getAllActiveTutors()
|
||||||
|
.toObservable()
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread());
|
||||||
|
}
|
||||||
|
|
||||||
|
private Observable<Coordinate> getCoordinateObservable(User user) {
|
||||||
|
return coordinateService
|
||||||
|
.getTopCoordinateByUserId(user.getId())
|
||||||
|
.toObservable()
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread());
|
||||||
|
}
|
||||||
|
|
||||||
private void fetchTopCords(){
|
private void fetchTopCords(){
|
||||||
disposable.add(
|
tutorsTimeStamps.clear();
|
||||||
coordinateService.getTopCoordinates()
|
disposable.add(getListOfActiveUsers()
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribeWith(new DisposableSingleObserver<List<Coordinate>>() {
|
.flatMap((Function<List<User>, Observable<User>>) Observable::fromIterable)
|
||||||
@Override
|
.flatMap((Function<User, ObservableSource<Coordinate>>) this::getCoordinateObservable)
|
||||||
public void onSuccess(List<Coordinate> newCords) {
|
.subscribeWith(new DisposableObserver<Coordinate>() {
|
||||||
for (Coordinate crd :
|
@Override
|
||||||
newCords) {
|
public void onNext(Coordinate coordinate) {
|
||||||
Long ts = crd.getTimeStamp();
|
Long ts = coordinate.getTimeStamp();
|
||||||
if (ts != 0){
|
tutorsTimeStamps.put(coordinate.getUserId(), getDate(ts));
|
||||||
tutorsTimeStamps.put(crd.getUserId(), getDate(ts));
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
mAdapter.notifyDataSetChanged();
|
|
||||||
|
|
||||||
}
|
@Override
|
||||||
|
public void onError(Throwable e) {showError(e);}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(Throwable e) {showSearchError(e);}
|
public void onComplete() {
|
||||||
}));
|
Log.e("USERS", String.valueOf(tutorsTimeStamps));
|
||||||
|
mAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getDate(long time) {
|
private String getDate(long time) {
|
||||||
@ -472,4 +497,4 @@ public class UsersListFragment extends Fragment {
|
|||||||
String date = DateFormat.format("HH:mm dd/MM", cal).toString();
|
String date = DateFormat.format("HH:mm dd/MM", cal).toString();
|
||||||
return date;
|
return date;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
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.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.RequiresApi;
|
||||||
import android.support.design.widget.FloatingActionButton;
|
import android.support.design.widget.FloatingActionButton;
|
||||||
import android.support.design.widget.Snackbar;
|
import android.support.design.widget.Snackbar;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
@ -27,6 +30,7 @@ import android.widget.Switch;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
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.WhiteListAdapter;
|
import com.uam.wmi.findmytutor.adapters.WhiteListAdapter;
|
||||||
@ -35,6 +39,7 @@ import com.uam.wmi.findmytutor.model.StudentIdModel;
|
|||||||
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.UserService;
|
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.MyDividerItemDecoration;
|
||||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||||
import com.uam.wmi.findmytutor.utils.RecyclerTouchListener;
|
import com.uam.wmi.findmytutor.utils.RecyclerTouchListener;
|
||||||
@ -68,6 +73,11 @@ public class WhiteList extends AppCompatActivity {
|
|||||||
Switch aSwitch;
|
Switch aSwitch;
|
||||||
@BindView(R.id.add_to_white_list_fab)
|
@BindView(R.id.add_to_white_list_fab)
|
||||||
FloatingActionButton addToWhiteListFab;
|
FloatingActionButton addToWhiteListFab;
|
||||||
|
|
||||||
|
@BindView(R.id.loader)
|
||||||
|
SpinKitView loader;
|
||||||
|
|
||||||
|
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
private UserService userService;
|
private UserService userService;
|
||||||
private boolean didFetched = false;
|
private boolean didFetched = false;
|
||||||
@ -77,12 +87,19 @@ public class WhiteList extends AppCompatActivity {
|
|||||||
private List<User> whitelistedUsers = new ArrayList<>();
|
private List<User> whitelistedUsers = new ArrayList<>();
|
||||||
private Collator plCollator = Collator.getInstance(Locale.forLanguageTag("pl-PL"));
|
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
|
@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);
|
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||||
setContentView(R.layout.activity_white_list);
|
setContentView(R.layout.activity_white_list);
|
||||||
ButterKnife.bind(this);
|
ButterKnife.bind(this);
|
||||||
|
|
||||||
tutorId = PrefUtils.getUserId(getApplicationContext());
|
tutorId = PrefUtils.getUserId(getApplicationContext());
|
||||||
userService = ApiClient.getClient(getApplicationContext())
|
userService = ApiClient.getClient(getApplicationContext())
|
||||||
.create(UserService.class);
|
.create(UserService.class);
|
||||||
@ -106,6 +123,7 @@ public class WhiteList extends AppCompatActivity {
|
|||||||
recyclerView.setItemAnimator(new DefaultItemAnimator());
|
recyclerView.setItemAnimator(new DefaultItemAnimator());
|
||||||
recyclerView.addItemDecoration(new MyDividerItemDecoration(this, LinearLayoutManager.VERTICAL, 16));
|
recyclerView.addItemDecoration(new MyDividerItemDecoration(this, LinearLayoutManager.VERTICAL, 16));
|
||||||
recyclerView.setAdapter(mAdapter);
|
recyclerView.setAdapter(mAdapter);
|
||||||
|
noNotesView.setVisibility(View.GONE);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On long press on RecyclerView item, open alert dialog
|
* On long press on RecyclerView item, open alert dialog
|
||||||
@ -258,17 +276,20 @@ public class WhiteList extends AppCompatActivity {
|
|||||||
private void toggleEmptyNotes() {
|
private void toggleEmptyNotes() {
|
||||||
|
|
||||||
if (didFetched && whitelistedUsers.size() == 0) {
|
if (didFetched && whitelistedUsers.size() == 0) {
|
||||||
noNotesView.setText(R.string.list_is_empty);
|
|
||||||
noNotesView.setVisibility(View.VISIBLE);
|
noNotesView.setVisibility(View.VISIBLE);
|
||||||
|
noNotesView.setText(R.string.list_is_empty);
|
||||||
|
loader.setVisibility(View.GONE);
|
||||||
} else if (whitelistedUsers.size() > 0) {
|
} else if (whitelistedUsers.size() > 0) {
|
||||||
noNotesView.setVisibility(View.GONE);
|
noNotesView.setVisibility(View.GONE);
|
||||||
|
loader.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
noNotesView.setText(getString(R.string.loading));
|
loader.setVisibility(View.VISIBLE);
|
||||||
noNotesView.setVisibility(View.VISIBLE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ 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;
|
||||||
|
|
||||||
@ -49,17 +50,22 @@ public class TutorsListAdapter extends RecyclerView.Adapter<TutorsListAdapter.My
|
|||||||
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.setText(R.string.available_now);
|
||||||
|
holder.loader.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
image = context.getResources().getDrawable(R.drawable.user_list_offline);
|
image = context.getResources().getDrawable(R.drawable.user_list_offline);
|
||||||
String ts = tutorsTimeStamps.get(tutor.getId());
|
String ts = tutorsTimeStamps.get(tutor.getId());
|
||||||
|
|
||||||
if (ts != null){
|
if (ts != null){
|
||||||
holder.lastSeen.setText(String.format("%s: %s", context.getResources().getString(R.string.last_seen), ts));
|
holder.lastSeen.setText(R.string.last_sign);
|
||||||
|
holder.lastSeen.append(String.format(": %s", ts));
|
||||||
|
holder.loader.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tutor.isIsActive()) {
|
if (!tutor.isIsActive()) {
|
||||||
image = context.getResources().getDrawable(R.drawable.user_list_off);
|
image = context.getResources().getDrawable(R.drawable.user_list_off);
|
||||||
|
holder.lastSeen.setText("");
|
||||||
|
holder.loader.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
image.setBounds(0, 0, image.getIntrinsicWidth(), image.getIntrinsicHeight());
|
image.setBounds(0, 0, image.getIntrinsicWidth(), image.getIntrinsicHeight());
|
||||||
@ -82,6 +88,9 @@ public class TutorsListAdapter extends RecyclerView.Adapter<TutorsListAdapter.My
|
|||||||
@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);
|
||||||
|
@ -25,7 +25,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> getTopCoordinatesByUserId(@Path("userId") String userId);
|
Single <Coordinate> getTopCoordinateByUserId(@Path("userId") String userId);
|
||||||
|
|
||||||
@GET("api/coordinates/top")
|
@GET("api/coordinates/top")
|
||||||
Single<List<Coordinate>> getTopCoordinates();
|
Single<List<Coordinate>> getTopCoordinates();
|
||||||
@ -42,4 +42,6 @@ public interface CoordinateService {
|
|||||||
@DELETE("api/coordinates/{id}")
|
@DELETE("api/coordinates/{id}")
|
||||||
Completable deleteCoordinatesById(@Path("id") String id);
|
Completable deleteCoordinatesById(@Path("id") String id);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,80 @@
|
|||||||
|
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,10 +1,32 @@
|
|||||||
package com.uam.wmi.findmytutor.utils;
|
package com.uam.wmi.findmytutor.utils;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
import android.os.Build;
|
||||||
import android.support.v4.os.ConfigurationCompat;
|
import android.support.v4.os.ConfigurationCompat;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
public class LocaleUtils {
|
public class LocaleUtils {
|
||||||
public static String getCurrentLocale(){
|
public static String getCurrentLocale() {
|
||||||
return String.valueOf(ConfigurationCompat.getLocales(Resources.getSystem().getConfiguration()));
|
return String.valueOf(ConfigurationCompat.getLocales(Resources.getSystem().getConfiguration()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Context updateResources(Context context, String language) {
|
||||||
|
Locale locale = new Locale(language);
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,30 +5,29 @@
|
|||||||
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="wrap_content"
|
android:layout_height="@dimen/app_bar_height"
|
||||||
|
android:fitsSystemWindows="true"
|
||||||
android:theme="@style/AppTheme.AppBarOverlay">
|
android:theme="@style/AppTheme.AppBarOverlay">
|
||||||
|
|
||||||
<android.support.v7.widget.Toolbar
|
<android.support.design.widget.CollapsingToolbarLayout
|
||||||
android:id="@+id/toolbar"
|
android:id="@+id/toolbar_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="?attr/actionBarSize"
|
android:layout_height="match_parent"
|
||||||
android:background="?attr/colorPrimary"
|
android:fitsSystemWindows="true"
|
||||||
app:popupTheme="@style/AppTheme.PopupOverlay" />
|
app:contentScrim="?attr/colorPrimary"
|
||||||
|
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>
|
@ -40,7 +40,7 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
android:text="@string/be_visible_for_these_users "
|
android:text="@string/be_visible_for_these_users"
|
||||||
android:textSize="15sp"/>
|
android:textSize="15sp"/>
|
||||||
|
|
||||||
<Switch
|
<Switch
|
||||||
|
@ -28,6 +28,21 @@
|
|||||||
android:textColor="@color/msg_no_notes"
|
android:textColor="@color/msg_no_notes"
|
||||||
android:textSize="@dimen/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>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
<?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"
|
<android.support.design.widget.CoordinatorLayout 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: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:fitsSystemWindows="true"
|
android:fitsSystemWindows="true"
|
||||||
android:id="@+id/activity_whitelist_container"
|
android:id="@+id/activity_tutor_content"
|
||||||
tools:context=".activity.WhiteList">
|
tools:context=".activity.TutorTab">
|
||||||
|
|
||||||
|
|
||||||
<android.support.design.widget.AppBarLayout
|
<android.support.design.widget.AppBarLayout
|
||||||
android:id="@+id/app_bar"
|
android:id="@+id/app_bar"
|
||||||
@ -57,10 +58,4 @@
|
|||||||
|
|
||||||
<include layout="@layout/content_tutor_tab_layout" />
|
<include layout="@layout/content_tutor_tab_layout" />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- A RecyclerView with some commonly used attributes -->
|
|
||||||
|
|
||||||
|
|
||||||
</android.support.design.widget.CoordinatorLayout>
|
</android.support.design.widget.CoordinatorLayout>
|
@ -1,14 +1,15 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
<android.support.v4.widget.NestedScrollView 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"
|
||||||
|
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:fillViewport="true"
|
android:fillViewport="true"
|
||||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||||
tools:context=".activity.TutorTab"
|
tools:context=".activity.TutorTab"
|
||||||
tools:showIn="@layout/content_tutor_tab2">
|
android:fontFamily="@font/lato_regular"
|
||||||
|
tools:showIn="@layout/content_tutor_tab">
|
||||||
|
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout 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"
|
||||||
@ -113,6 +114,7 @@
|
|||||||
android:layout_below="@+id/userRoomLayout"
|
android:layout_below="@+id/userRoomLayout"
|
||||||
android:layout_alignStart="@+id/userRoomLayout"
|
android:layout_alignStart="@+id/userRoomLayout"
|
||||||
android:layout_marginStart="0dp"
|
android:layout_marginStart="0dp"
|
||||||
|
android:layout_marginEnd="30dp"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:text="@string/dutyTitle"
|
android:text="@string/dutyTitle"
|
||||||
@ -122,7 +124,7 @@
|
|||||||
|
|
||||||
<android.support.v7.widget.RecyclerView
|
<android.support.v7.widget.RecyclerView
|
||||||
android:id="@+id/dutyHourView"
|
android:id="@+id/dutyHourView"
|
||||||
android:layout_width="300dp"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="100dp"
|
android:layout_height="100dp"
|
||||||
android:layout_below="@+id/addDuty"
|
android:layout_below="@+id/addDuty"
|
||||||
|
|
||||||
@ -135,7 +137,7 @@
|
|||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/userNoteTitle"
|
android:id="@+id/userNoteTitle"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/dutyHourView"
|
android:layout_below="@+id/dutyHourView"
|
||||||
android:layout_alignStart="@+id/userRoomLayout"
|
android:layout_alignStart="@+id/userRoomLayout"
|
||||||
@ -143,21 +145,24 @@
|
|||||||
android:textColor="@color/mapboxRedDark"
|
android:textColor="@color/mapboxRedDark"
|
||||||
android:textSize="18sp" />
|
android:textSize="18sp" />
|
||||||
|
|
||||||
<Button
|
<android.support.v7.widget.AppCompatButton
|
||||||
android:id="@+id/addDuty"
|
android:id="@+id/addDuty"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
app:backgroundTint="@color/colorPrimary"
|
||||||
android:layout_alignBaseline="@+id/dutyTitle"
|
android:layout_alignBaseline="@+id/dutyTitle"
|
||||||
android:layout_toEndOf="@+id/userRoomLayout"
|
android:layout_toEndOf="@+id/dutyTitle"
|
||||||
android:text="@string/addDuty" />
|
android:text="@string/addDuty" />
|
||||||
|
|
||||||
<android.support.design.widget.TextInputLayout
|
<android.support.design.widget.TextInputLayout
|
||||||
android:id="@+id/userNoteLayout"
|
android:id="@+id/userNoteLayout"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/userNoteTitle"
|
android:layout_below="@+id/userNoteTitle"
|
||||||
android:layout_alignParentStart="true"
|
android:layout_alignParentStart="true"
|
||||||
android:layout_marginStart="30dp"
|
android:layout_marginStart="30dp"
|
||||||
|
android:layout_marginEnd="30dp"
|
||||||
android:layout_marginTop="0dp"
|
android:layout_marginTop="0dp"
|
||||||
app:counterEnabled="true"
|
app:counterEnabled="true"
|
||||||
app:counterMaxLength="1000">
|
app:counterMaxLength="1000">
|
||||||
@ -165,7 +170,7 @@
|
|||||||
<android.support.design.widget.TextInputEditText
|
<android.support.design.widget.TextInputEditText
|
||||||
|
|
||||||
android:id="@+id/userNote"
|
android:id="@+id/userNote"
|
||||||
android:layout_width="300dp"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="100dp"
|
android:layout_height="100dp"
|
||||||
android:layout_alignStart="@+id/userNoteLayout"
|
android:layout_alignStart="@+id/userNoteLayout"
|
||||||
android:hint="@string/tutorTabHint"
|
android:hint="@string/tutorTabHint"
|
||||||
@ -179,21 +184,24 @@
|
|||||||
android:textColor="@color/note_list_text" />
|
android:textColor="@color/note_list_text" />
|
||||||
</android.support.design.widget.TextInputLayout>
|
</android.support.design.widget.TextInputLayout>
|
||||||
|
|
||||||
<Button
|
<android.support.v7.widget.AppCompatButton
|
||||||
android:id="@+id/scrapTutorTab"
|
android:id="@+id/scrapTutorTab"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignBaseline="@+id/personalInfoTitle"
|
android:layout_alignBaseline="@+id/personalInfoTitle"
|
||||||
android:layout_alignEnd="@+id/userEmailLayout"
|
android:layout_alignEnd="@+id/userEmailLayout"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
app:backgroundTint="@color/colorPrimary"
|
||||||
android:text="@string/scrap_tutor_tab" />
|
android:text="@string/scrap_tutor_tab" />
|
||||||
|
|
||||||
<Button
|
<android.support.v7.widget.AppCompatButton
|
||||||
|
android:id="@+id/saveButton"
|
||||||
android:id="@+id/saveButon"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/userNoteLayout"
|
android:layout_below="@+id/userNoteLayout"
|
||||||
android:layout_alignEnd="@+id/dutyHourView"
|
android:layout_alignEnd="@+id/dutyHourView"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
app:backgroundTint="@color/colorPrimary"
|
||||||
android:text="@string/saveButton" />
|
android:text="@string/saveButton" />
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,6 +28,20 @@
|
|||||||
android:textColor="@color/msg_no_notes"
|
android:textColor="@color/msg_no_notes"
|
||||||
android:textSize="@dimen/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>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
@ -1,13 +1,22 @@
|
|||||||
<?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"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -19,9 +19,20 @@
|
|||||||
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/lastSeen"
|
||||||
android:layout_width="270dp"
|
android:layout_width="270dp"
|
||||||
@ -35,7 +46,6 @@
|
|||||||
android:textColor="#979797"
|
android:textColor="#979797"
|
||||||
android:textSize="13sp" />
|
android:textSize="13sp" />
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/isOnline"
|
android:id="@+id/isOnline"
|
||||||
android:layout_width="50dp"
|
android:layout_width="50dp"
|
||||||
|
@ -27,5 +27,20 @@
|
|||||||
android:textSize="@dimen/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>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
<string name="navigation_item_blacklist">Czarna lista</string>
|
<string name="navigation_item_blacklist">Czarna lista</string>
|
||||||
<string name="navigation_item_whitelist">Biała lista</string>
|
<string name="navigation_item_whitelist">Biała lista</string>
|
||||||
<string name="navigation_item_settings">Ustawienia</string>
|
<string name="navigation_item_settings">Ustawienia</string>
|
||||||
<string name="navigation_item_profile">Profil uzytkownika</string>
|
<string name="navigation_item_profile">Profil użytkownika</string>
|
||||||
<string name="navigation_item_logout">Wyloguj</string>
|
<string name="navigation_item_logout">Wyloguj</string>
|
||||||
<!-- Tutors list -->
|
<!-- Tutors list -->
|
||||||
<string name="action_settings">Ustawienia</string>
|
<string name="action_settings">Ustawienia</string>
|
||||||
@ -284,10 +284,10 @@
|
|||||||
<string name="exact_mode">dokładny</string>
|
<string name="exact_mode">dokładny</string>
|
||||||
<string name="approx_mode">przybliżony</string>
|
<string name="approx_mode">przybliżony</string>
|
||||||
<string name="other_location">Niezapisana lokalizacja.</string>
|
<string name="other_location">Niezapisana lokalizacja.</string>
|
||||||
<string name="last_seen">Ostatnio</string>
|
<string name="last_sign">Ostatnio</string>
|
||||||
<string name="available_now">Dostępny teraz</string>
|
|
||||||
<string name="profile_activity_title">Profil</string>
|
|
||||||
|
|
||||||
|
<string name="available_now">Dostępny teraz</string>
|
||||||
|
<string name="profile_activity_title">Profil użytkownika</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
||||||
|
@ -455,5 +455,5 @@
|
|||||||
<string name="other_location">Not saved location.</string>
|
<string name="other_location">Not saved location.</string>
|
||||||
<string name="user_status_label" translatable="false">Status</string>
|
<string name="user_status_label" translatable="false">Status</string>
|
||||||
<string name="available_now">Available now</string>
|
<string name="available_now">Available now</string>
|
||||||
<string name="last_seen">Last seen</string>
|
<string name="last_sign">Last seen</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?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:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/pref_screen"
|
android:id="@+id/pref_screen"
|
||||||
|
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:fontFamily="@font/lato_regular">
|
android:fontFamily="@font/lato_regular">
|
||||||
@ -58,6 +59,8 @@
|
|||||||
android:title="@string/title_manual_status" />
|
android:title="@string/title_manual_status" />
|
||||||
<com.uam.wmi.findmytutor.utils.RightButtonPreference
|
<com.uam.wmi.findmytutor.utils.RightButtonPreference
|
||||||
android:key="remove_manual_status"
|
android:key="remove_manual_status"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
app:backgroundTint="@color/mapboxRedDark"
|
||||||
android:text="@string/preference_manual_status_button_remove" />
|
android:text="@string/preference_manual_status_button_remove" />
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
Loading…
Reference in New Issue
Block a user