Merge branch 'develop' of s416084/find-my-tutor-android into master

This commit is contained in:
Mieszko Wrzeszczyński 2019-01-06 11:02:30 +00:00 committed by Gogs
commit 7e043c9826
62 changed files with 3289 additions and 348 deletions

View File

@ -10,8 +10,8 @@ android {
applicationId "com.uam.wmi.findmytutor"
minSdkVersion 22
targetSdkVersion 27
versionCode 21
versionName "0.9.5-beta"
versionCode 37
versionName "0.9.6-beta"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
@ -72,4 +72,6 @@ dependencies {
// FloatingBarMenu
implementation 'com.getbase:floatingactionbutton:1.10.1'
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'
}

Binary file not shown.

Binary file not shown.

View File

@ -27,10 +27,10 @@
tools:ignore="AllowBackup,GoogleAppIndexingWarning">
<activity
android:name=".activity.StartupActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:launchMode="singleInstance"
android:theme="@style/AppTheme.NoActionBar"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation|screenSize">
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@ -38,33 +38,43 @@
</intent-filter>
</activity>
<activity
android:windowSoftInputMode="adjustPan"
android:name=".activity.MapActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:launchMode="singleTop"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation|screenSize"/>
android:screenOrientation="portrait" />
<activity
android:name=".activity.LoginActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:excludeFromRecents="true"
android:launchMode="singleTask"
android:noHistory="true"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation|screenSize"/>
android:screenOrientation="portrait" />
<activity
android:name=".activity.SettingsActivity"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation|screenSize"/>
android:configChanges="keyboardHidden|orientation|screenSize"
android:screenOrientation="portrait" />
<service
android:name=".service.BackgroundLocalizationService"
android:enabled="true"
android:exported="false"
android:launchMode="singleTop" />
<activity
android:name=".activity.TutorTab"
android:theme="@style/AppTheme"
android:configChanges="keyboardHidden|orientation|screenSize"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation|screenSize"/>
android:theme="@style/AppTheme" />
<activity
android:name=".activity.WhiteList"
android:configChanges="keyboardHidden|orientation|screenSize"
android:screenOrientation="portrait"
android:theme="@style/AppTheme" />
<activity
android:name=".activity.BlackList"
android:configChanges="keyboardHidden|orientation|screenSize"
android:screenOrientation="portrait"
android:theme="@style/AppTheme" />
</application>
</manifest>

View File

@ -0,0 +1,727 @@
{
"features": [
{
"type": "Feature",
"properties": {
"name": "Pokoje profesorskie"
},
"geometry": {
"coordinates": [
[
[
16.926707,
52.46657
],
[
16.92652,
52.466244
],
[
16.926459,
52.466255
],
[
16.926645,
52.466582
],
[
16.926707,
52.46657
]
]
],
"type": "Polygon"
},
"id": "07f45cd94d45bb5ad0b6b285b0f6fbbb"
},
{
"type": "Feature",
"properties": {
"name": "Skrzydło B"
},
"geometry": {
"coordinates": [
[
[
16.926961,
52.467026
],
[
16.92677,
52.466682
],
[
16.92652,
52.466244
],
[
16.926459,
52.466255
],
[
16.926428,
52.466203
],
[
16.926175,
52.46625
],
[
16.92621,
52.466306
],
[
16.926323,
52.466282
],
[
16.926515,
52.466632
],
[
16.926408,
52.466654
],
[
16.92644,
52.466712
],
[
16.926543,
52.46669
],
[
16.926754,
52.467067
],
[
16.926961,
52.467026
]
]
],
"type": "Polygon"
},
"id": "143facf35f322434cfc5776f70f1db36"
},
{
"type": "Feature",
"properties": {
"name": "Winda"
},
"geometry": {
"coordinates": [
[
[
16.92669,
52.467141
],
[
16.92666,
52.467089
],
[
16.926755,
52.46707
],
[
16.926786,
52.467121
],
[
16.92669,
52.467141
]
]
],
"type": "Polygon"
},
"id": "1a35bfafd619b80ffb8b36f03549e9e3"
},
{
"type": "Feature",
"properties": {
"name": "D2"
},
"geometry": {
"coordinates": [
[
[
16.926876,
52.466659
],
[
16.926984,
52.466635
],
[
16.92694,
52.466557
],
[
16.926831,
52.46658
],
[
16.926876,
52.466659
]
]
],
"type": "Polygon"
},
"id": "3e0a32a0583254e9e7c47fea1f402472"
},
{
"type": "Feature",
"properties": {
"name": "Sale A"
},
"geometry": {
"coordinates": [
[
[
16.92714,
52.466489
],
[
16.926925,
52.466127
],
[
16.927027,
52.466106
],
[
16.927232,
52.466472
],
[
16.92714,
52.466489
]
]
],
"type": "Polygon"
},
"id": "3e56cb54baf90049a3ce2f16577c2cd8"
},
{
"type": "Feature",
"properties": {
"name": "D1"
},
"geometry": {
"coordinates": [
[
[
16.926984,
52.466635
],
[
16.927084,
52.466614
],
[
16.92704,
52.466536
],
[
16.92694,
52.466557
],
[
16.926984,
52.466635
]
]
],
"type": "Polygon"
},
"id": "56c2a7ab4e4d2ac14a46448d523470dc"
},
{
"type": "Feature",
"properties": {
"name": "Hol"
},
"geometry": {
"coordinates": [
[
[
16.927104,
52.467081
],
[
16.927039,
52.467095
],
[
16.9268,
52.467145
],
[
16.926754,
52.467067
],
[
16.926961,
52.467026
],
[
16.927277,
52.46696
],
[
16.927272,
52.466951
],
[
16.927451,
52.466918
],
[
16.927494,
52.467002
],
[
16.927278,
52.467047
],
[
16.927144,
52.467073
],
[
16.927104,
52.467081
]
]
],
"type": "Polygon"
},
"id": "6f1db27a4df5a46f7a6913556b01effe"
},
{
"type": "Feature",
"properties": {
"name": "Pokoje profesorskie"
},
"geometry": {
"coordinates": [
[
[
16.92677,
52.466683
],
[
16.926961,
52.467026
],
[
16.926887,
52.467041
],
[
16.926695,
52.466699
],
[
16.92677,
52.466683
]
]
],
"type": "Polygon"
},
"id": "94f310dcaa6cee75d9e7800bf8d94155"
},
{
"type": "Feature",
"properties": {
"name": "Biblioteka"
},
"geometry": {
"coordinates": [
[
[
16.926801,
52.467144
],
[
16.926971,
52.467424
],
[
16.926956,
52.46743
],
[
16.926944,
52.467436
],
[
16.92693,
52.467441
],
[
16.926903,
52.467452
],
[
16.926861,
52.467464
],
[
16.926778,
52.467476
],
[
16.926731,
52.467485
],
[
16.926567,
52.467194
],
[
16.926801,
52.467144
]
]
],
"type": "Polygon"
},
"id": "aadab5775bdeb4eaf82c940255ddadd7"
},
{
"type": "Feature",
"properties": {
"name": "Sale A"
},
"geometry": {
"coordinates": [
[
[
16.927082,
52.466492
],
[
16.926999,
52.466509
],
[
16.926771,
52.466109
],
[
16.926857,
52.466088
],
[
16.927082,
52.466492
]
]
],
"type": "Polygon"
},
"id": "b39857ed605e5794fa6c9cdee5d7d6cf"
},
{
"type": "Feature",
"properties": {
"name": "Pokoje profesorskie"
},
"geometry": {
"coordinates": [
[
[
16.926754,
52.467066
],
[
16.926814,
52.467054
],
[
16.926605,
52.466676
],
[
16.926542,
52.46669
],
[
16.926564,
52.466728
],
[
16.926754,
52.467066
]
]
],
"type": "Polygon"
},
"id": "b754d867fde3826e72fe8c243399ff26"
},
{
"type": "Feature",
"properties": {
"name": "Sale A"
},
"geometry": {
"coordinates": [
[
[
16.927272,
52.46695
],
[
16.927083,
52.466613
],
[
16.927167,
52.466595
],
[
16.92735,
52.466936
],
[
16.927272,
52.46695
]
]
],
"type": "Polygon"
},
"id": "c3726b2a2b3a589995fd3f17eecd1f53"
},
{
"type": "Feature",
"properties": {
"name": "D3"
},
"geometry": {
"coordinates": [
[
[
16.92677,
52.466682
],
[
16.926876,
52.466659
],
[
16.926832,
52.46658
],
[
16.926725,
52.466604
],
[
16.92677,
52.466682
]
]
],
"type": "Polygon"
},
"id": "c73d9bdbccc15d9907e24b8bb731118a"
},
{
"type": "Feature",
"properties": {
"name": "Pokoje profesorskie"
},
"geometry": {
"coordinates": [
[
[
16.926324,
52.466282
],
[
16.926503,
52.46661
],
[
16.926579,
52.466595
],
[
16.926398,
52.466268
],
[
16.926324,
52.466282
]
]
],
"type": "Polygon"
},
"id": "d54475cedfa0a866e13933c56bf35d76"
},
{
"type": "Feature",
"properties": {
"name": "Sale A"
},
"geometry": {
"coordinates": [
[
[
16.927607,
52.466891
],
[
16.92734,
52.466562
],
[
16.927242,
52.466585
],
[
16.927451,
52.466918
],
[
16.927607,
52.466891
]
]
],
"type": "Polygon"
},
"id": "d97989e446002de50bc8844d2d9cdf5c"
},
{
"type": "Feature",
"properties": {
"name": "Winda"
},
"geometry": {
"coordinates": [
[
[
16.92669,
52.467141
],
[
16.92666,
52.467089
],
[
16.926755,
52.46707
],
[
16.926786,
52.467121
],
[
16.92669,
52.467141
]
]
],
"type": "Polygon"
},
"id": "dfdba4ee1ee0c55193b8dd04f8b00f6c"
},
{
"type": "Feature",
"properties": {
"name": "Skrzydło A"
},
"geometry": {
"coordinates": [
[
[
16.927606,
52.466891
],
[
16.927339,
52.466562
],
[
16.927242,
52.466585
],
[
16.92718,
52.466482
],
[
16.927232,
52.466473
],
[
16.927025,
52.466105
],
[
16.926924,
52.466126
],
[
16.926896,
52.466078
],
[
16.92677,
52.466108
],
[
16.926998,
52.466509
],
[
16.927041,
52.466537
],
[
16.927075,
52.466595
],
[
16.927082,
52.466614
],
[
16.927277,
52.46696
],
[
16.927358,
52.466942
],
[
16.927354,
52.466935
],
[
16.92745,
52.466918
],
[
16.927606,
52.466891
]
]
],
"type": "Polygon"
},
"id": "faaa569e3642a741f70a77071f19f131"
}
],
"type": "FeatureCollection"
}

View File

@ -53,6 +53,7 @@ import io.reactivex.schedulers.Schedulers;
import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext;
import static com.uam.wmi.findmytutor.utils.Const.defaultMapZoom;
import static com.uam.wmi.findmytutor.utils.Const.onlineBackgroundLocationInterval;
import static com.uam.wmi.findmytutor.utils.Const.searchMapZoom;
import static com.uam.wmi.findmytutor.utils.PrefUtils.storeBackgroundLocationStatus;
@ -99,11 +100,11 @@ public abstract class BaseActivity
String itemName = (String) item.getTitle();
Intent launchIntent;
if (itemName.equals(getResources().getString(R.string.navigation_item_whitelist))) {
/* launchIntent = new Intent(getApplicationContext(), WhitelistActivity.class);
startActivity(launchIntent);*/
launchIntent = new Intent(getApplicationContext(), WhiteList.class);
startActivity(launchIntent);
} else if (itemName.equals(getResources().getString(R.string.navigation_item_blacklist))) {
/* launchIntent = new Intent(getApplicationContext(), BlacklistActivity.class);
startActivity(launchIntent);*/
launchIntent = new Intent(getApplicationContext(),BlackList.class);
startActivity(launchIntent);
} else if (itemName.equals(getResources().getString(R.string.navigation_item_profile))) {
@ -200,7 +201,6 @@ public abstract class BaseActivity
public void stopBackgroundLocalizationTask() {
Intent stopIntent = new Intent(getApplicationContext(), BackgroundLocalizationService.class);
stopIntent.putExtra("request_stop", true);
Log.e("Localization", "JEstem w stop BG");
stopService(stopIntent);
@ -210,6 +210,7 @@ public abstract class BaseActivity
checkPermissions();
Intent startIntent = new Intent(getApplicationContext(), BackgroundLocalizationService.class);
startIntent.putExtra("notify_interval", onlineBackgroundLocationInterval);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O) {
startForegroundService(startIntent);
@ -219,17 +220,12 @@ public abstract class BaseActivity
}
public void handleBackgroundTaskLifeCycle() {
Log.e("Localization", String.valueOf(PrefUtils.isEnableSharingLocalization(getApplicationContext())));
Boolean shouldServiceRun = PrefUtils.isEnableSharingLocalization(getApplicationContext()) && isTutor;
Log.e("Localization", String.valueOf(shouldServiceRun));
if (shouldServiceRun) {
startBackgroundLocalizationTask();
Log.e("Localization", "JEstem i odpalam");
} else {
stopBackgroundLocalizationTask();
Log.e("Localization", "JEstem i nie odpalam");
}
}
@ -285,7 +281,6 @@ public abstract class BaseActivity
getMenuInflater().inflate(R.menu.menu_main, menu);
infoMenuItem = menu.findItem(R.id.action_info);
MenuItem myActionMenuItem = menu.findItem(R.id.action_search);
searchView = (SearchView) myActionMenuItem.getActionView();
@ -295,6 +290,10 @@ public abstract class BaseActivity
adjustMapToSearch(defaultMapZoom);
}
if (!hasFocus && activeFragment.equals(ActiveFragment.USER_LIST)) {
((UsersListFragment) userListFragment).restoreUsersList();
}
if(hasFocus && activeFragment.equals(ActiveFragment.NONE)){
adjustMapToSearch(searchMapZoom);
}
@ -303,6 +302,7 @@ public abstract class BaseActivity
RxSearchObservable.fromView(searchView)
.skip(0)
.map(String::toLowerCase)
.filter(t -> !t.isEmpty())
.debounce(250, TimeUnit.MILLISECONDS)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
@ -389,11 +389,14 @@ public abstract class BaseActivity
if (itemId == R.id.nav_map) {
removeFragment(sharingFragment);
removeFragment(userListFragment);
activeFragment = ActiveFragment.NONE;
activeFragment = ActiveFragment.NONE;
findViewById(R.id.action_search).setVisibility(View.VISIBLE);
} else if (itemId == R.id.nav_profile) {
loadUserSettingsFragment();
findViewById(R.id.action_search).setVisibility(View.GONE);
} else if (itemId == R.id.nav_user_list) {
loadUserListFragment();
findViewById(R.id.action_search).setVisibility(View.VISIBLE);
}
selectBottomNavigationBarItem(itemId);
}, 300);

View File

@ -0,0 +1,363 @@
package com.uam.wmi.findmytutor.activity;
import android.annotation.SuppressLint;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.Switch;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ToggleButton;
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
import com.mapbox.geojson.Point;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.uam.wmi.findmytutor.R;
import com.uam.wmi.findmytutor.adapters.BlackListAdapter;
import com.uam.wmi.findmytutor.model.IsUsingListBool;
import com.uam.wmi.findmytutor.model.PredefinedCoordViewModel;
import com.uam.wmi.findmytutor.model.StudentIdModel;
import com.uam.wmi.findmytutor.model.User;
import com.uam.wmi.findmytutor.model.UserResponseModel;
import com.uam.wmi.findmytutor.network.ApiClient;
import com.uam.wmi.findmytutor.service.PredefinedStatusesService;
import com.uam.wmi.findmytutor.service.UserService;
import com.uam.wmi.findmytutor.utils.MyDividerItemDecoration;
import com.uam.wmi.findmytutor.utils.PrefUtils;
import com.uam.wmi.findmytutor.utils.RecyclerTouchListener;
import com.uam.wmi.findmytutor.utils.RestApiHelper;
import com.uam.wmi.findmytutor.utils.SharingLevel;
import com.uam.wmi.findmytutor.utils.WrapContentLinearLayoutManager;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import butterknife.BindView;
import butterknife.ButterKnife;
import io.reactivex.Observable;
import io.reactivex.ObservableSource;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.functions.Function;
import io.reactivex.observers.DisposableObserver;
import io.reactivex.observers.DisposableSingleObserver;
import io.reactivex.schedulers.Schedulers;
import okhttp3.ResponseBody;
public class BlackList extends AppCompatActivity {
private CompositeDisposable disposable = new CompositeDisposable();
private UserService userService;
private boolean didFetched = false;
private String tutorId;
@BindView(R.id.recycler_view_blacklist)
RecyclerView recyclerView;
@BindView(R.id.black_list_empty_text_view)
TextView noNotesView;
@BindView(R.id.switch_blacklist_toggle)
Switch aSwitch;
@BindView(R.id.add_to_black_list_fab)
FloatingActionButton addToBlackListFab;
private Integer prevSize;
private BlackListAdapter mAdapter;
private List<User> blacklistedUsers = new ArrayList<>();
private Collator plCollator = Collator.getInstance(Locale.forLanguageTag("pl-PL"));
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
setContentView(R.layout.activity_black_list);
ButterKnife.bind(this);
tutorId = PrefUtils.getUserId(getApplicationContext());
userService = ApiClient.getClient(getApplicationContext())
.create(UserService.class);
if (PrefUtils.isBlackListing(this)){
aSwitch.setText(getString(R.string.action_black_list) +" ON");
aSwitch.setChecked(true);
handleChangeRequest(true);
}else{
aSwitch.setText(getString(R.string.action_black_list) +" OFF");
aSwitch.setChecked(false);
handleChangeRequest(false);
}
Toolbar toolbar = findViewById(R.id.toolbar);
toolbar.setTitle(getString(R.string.activity_title_blacklist));
setSupportActionBar(toolbar);
mAdapter = new BlackListAdapter(this, blacklistedUsers);
recyclerView.setLayoutManager(new WrapContentLinearLayoutManager(getApplicationContext()));
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.addItemDecoration(new MyDividerItemDecoration(this, LinearLayoutManager.VERTICAL, 16));
recyclerView.setAdapter(mAdapter);
fetchBlackListedUsers();
/**
* On long press on RecyclerView item, open alert dialog
* with options to choose
* Edit and Delete
* */
recyclerView.addOnItemTouchListener(new RecyclerTouchListener(this,
recyclerView, new RecyclerTouchListener.ClickListener() {
@Override
public void onClick(View view, final int position) {
}
@Override
public void onLongClick(View view, int position) {
}
}));
addToBlackListFab.setOnClickListener(this::showFabDialog);
handleSwitch();
}
private Observable<List<String>> getListOfBlacklistedUsers(String userId) {
return userService.getTutorBlacklistedByID(userId)
.toObservable()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
private Observable<User> getUserObservable(String userId) {
return userService
.getUserById(userId)
.toObservable()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
private void fetchBlackListedUsers() {
prevSize = blacklistedUsers.size();
blacklistedUsers.clear();
disposable.add(getListOfBlacklistedUsers(tutorId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.flatMap((Function<List<String>, Observable<String>>) Observable::fromIterable)
.flatMap((Function<String, ObservableSource<User>>) this::getUserObservable)
.subscribeWith(new DisposableObserver<User>() {
@Override
public void onNext(User user) {
blacklistedUsers.add(user);
}
@Override
public void onError(Throwable e) {
showError(e);
}
@Override
public void onComplete() {
Collections.sort(blacklistedUsers, (a, b) -> sortByUserName(a,b));
refreshUI();
}
}));
}
private void refreshUI(){
toggleEmptyNotes();
mAdapter.notifyItemRangeInserted(prevSize, blacklistedUsers.size() - prevSize);
mAdapter.notifyDataSetChanged();
}
private int sortByUserName(User t1, User t2) {
return plCollator.compare(t1.getLastName(), t2.getLastName());
}
private void showFabDialog(View v){
LayoutInflater layoutInflaterAndroid = LayoutInflater.from(getApplicationContext());
@SuppressLint("InflateParams") View view = layoutInflaterAndroid.inflate(R.layout.black_list_fab_modal, null);
AlertDialog.Builder alertDialogBuilderUserInput = new android.support.v7.app.AlertDialog.Builder(this);
alertDialogBuilderUserInput.setView(view).setPositiveButton(getApplicationContext().getString(R.string.modal_location_send), null);
alertDialogBuilderUserInput
.setPositiveButton(R.string.add, null)
.setNegativeButton(R.string.cancel, null);
final AlertDialog alertDialog = alertDialogBuilderUserInput.create();
alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
EditText modalUserInput = view.findViewById(R.id.black_list_modal_input);
alertDialog.setOnShowListener(dialogInterface -> {
Button sendButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
Button dismissButton = alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE);
dismissButton.setOnClickListener(view1 -> alertDialog.dismiss());
sendButton.setOnClickListener(view1 -> {
String body = modalUserInput.getText().toString();
if (TextUtils.isEmpty(body)) {
Toast.makeText(getApplicationContext(), R.string.can_not_be_empty, Toast.LENGTH_SHORT).show();
modalUserInput.requestFocus();
} else {
sendUserToBlacklist(body);
alertDialog.dismiss();
}
});
});
alertDialog.show();
}
private void sendUserToBlacklist(String body) {
StudentIdModel studentIdModel = new StudentIdModel(body);
disposable.add(
userService.addStudentToBlacklist(PrefUtils.getUserId(getApplicationContext()), studentIdModel)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(this::handleAddUser,this::showError)
);
}
private void handleAddUser(User user) {
Toast.makeText(this, R.string.add_user_to_list, Snackbar.LENGTH_LONG).show();
blacklistedUsers.clear();
fetchBlackListedUsers();
}
private void showError(Throwable e) {
String message;
if (e instanceof HttpException) {
ResponseBody responseBody = ((HttpException) e).response().errorBody();
message = RestApiHelper.getErrorMessage(responseBody);
if (((HttpException) e).response().code() == 404) {
message = getString(R.string.no_such_a_user);
}
} else {
message = "Network Error !";
}
Toast.makeText(this, message, Snackbar.LENGTH_LONG).show();
}
private void toggleEmptyNotes() {
if (didFetched && blacklistedUsers.size() == 0) {
noNotesView.setText(R.string.list_is_empty);
noNotesView.setVisibility(View.VISIBLE);
}else if (blacklistedUsers.size() > 0) {
noNotesView.setVisibility(View.GONE);
} else {
noNotesView.setText(getString(R.string.loading));
noNotesView.setVisibility(View.VISIBLE);
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_black_list, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId()==R.id.action_blacklist_info_popup){
int layoutID = R.layout.info_popup_blacklist;
View popupView = getLayoutInflater().inflate(layoutID,null);
PopupWindow popupWindow = new PopupWindow(popupView,
LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
// If the PopupWindow should be focusable
popupWindow.setFocusable(true);
// If you need the PopupWindow to dismiss when when touched outside
popupWindow.setBackgroundDrawable(new ColorDrawable());
// Get the View's(the one that was clicked in the Fragment) location
View anchorView= getWindow().getDecorView().findViewById(android.R.id.content);
popupWindow.showAtLocation(anchorView,Gravity.TOP|Gravity.END, 0, 0);
}
return super.onOptionsItemSelected(item);
}
private void handleSwitch(){
aSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (isChecked){
aSwitch.setText(getString(R.string.action_black_list) + " "+ getString(R.string.on));
handleChangeRequest(true);
PrefUtils.useBlacklist(this,true);
}else {
aSwitch.setText(getString(R.string.action_black_list) + " "+getString(R.string.off));
handleChangeRequest(false);
PrefUtils.useBlacklist(this,false);
}
});
}
private void handleChangeRequest(boolean value){
IsUsingListBool isUsingListBool = new IsUsingListBool();
isUsingListBool.setIsUsing(value);
disposable.add(
userService.setTutorBlacklist(tutorId, isUsingListBool)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(()->{
},this::showError)
);
}
@Override
public void onResume() {
super.onResume();
}
@Override
public void onPause() {
super.onPause();
}
@Override
public void onStop() {
super.onStop();
}
@Override
public void onDestroy() {
super.onDestroy();
disposable.dispose();
}
}

View File

@ -149,7 +149,7 @@ public class LoginActivity extends AppCompatActivity {
private void loginProcess(String email, String password) {
ValidateUser user = new ValidateUser(email, password);
//LdapUser fakeUser = new LdapUser(email, password,"wmi","tutor",email,"Fałszywy",email);
// LdapUser fakeUser = new LdapUser(email, password,"wmi","tutor",email,"Fałszywy",email);
disposable.add(ldapService.validate(user)
//disposable.add(ldapService.fakeValidate(fakeUser)
.subscribeOn(Schedulers.io())

View File

@ -44,6 +44,7 @@ import com.uam.wmi.findmytutor.model.PredefinedCoordViewModel;
import com.uam.wmi.findmytutor.model.User;
import com.uam.wmi.findmytutor.network.ApiClient;
import com.uam.wmi.findmytutor.service.CoordinateService;
import com.uam.wmi.findmytutor.service.PredefinedCoordinatesService;
import com.uam.wmi.findmytutor.service.PredefinedStatusesService;
import com.uam.wmi.findmytutor.service.UserService;
import com.uam.wmi.findmytutor.utils.ApproximatedLocalization;
@ -70,6 +71,8 @@ import io.reactivex.schedulers.Schedulers;
import okhttp3.ResponseBody;
import timber.log.Timber;
import static com.uam.wmi.findmytutor.utils.Const.mapRefreshInterval;
public class MapActivity extends BaseActivity
implements PermissionsListener, OnMapReadyCallback {
@ -80,7 +83,7 @@ public class MapActivity extends BaseActivity
private UserService userService;
private CompositeDisposable disposable = new CompositeDisposable();
private int mInterval = 10000;
private int mInterval = mapRefreshInterval;
private Handler mHandler = new Handler();
private Runnable mStatusChecker;
private MapView mapView;
@ -91,7 +94,7 @@ public class MapActivity extends BaseActivity
private Coordinate droppedMarkercoordinate;
private HashMap<String, Coordinate> coordsMap = new HashMap<>();
private HashMap<String, MapMarker> markerHash = new HashMap<>();
private HashMap<Long, String> markerUserHash = new HashMap<>();
public HashMap<Long, String> markerUserHash = new HashMap<>();
private Set<String> previousCoordsIds = new HashSet<>();
private ManualLocationUtils manualLocationUtils;
// Camera Animation params
@ -148,22 +151,7 @@ public class MapActivity extends BaseActivity
mapboxMap.setOnMarkerClickListener(marker -> {
String id = markerUserHash.get(marker.getId());
String locationLevel = PrefUtils.getLocationLevel(getApplicationContext());
/* if (id.equals(myId) && (locationLevel.equals(SharingLevel.MANUAL.toString()) || locationLevel.equals(SharingLevel.PREDEFINED.toString()))) {
selectLocationButton.setVisibility(View.GONE);
removeLocationButton.setVisibility(View.VISIBLE);
removeLocationButton.setOnClickListener(view -> {
stopBackgroundLocalizationTask();
removeLocationButton.setVisibility(View.GONE);
Toast.makeText(MapActivity.this, R.string.manual_marker_info, Toast.LENGTH_SHORT).show();
});
} else {*/
createMarkerModal(id);
/* }*/
createMarkerModal(id);
return true;
});
@ -246,7 +234,11 @@ public class MapActivity extends BaseActivity
}
private void setOnMapClickListener() {
mapboxMap.addOnMapClickListener(e -> removeLocationButton.setVisibility(View.GONE));
mapboxMap.addOnMapClickListener(e -> {
removeLocationButton.setVisibility(View.GONE);
selectLocationButton.setVisibility(View.GONE);
});
}
private void setOnMapLongClickListener() {
@ -333,7 +325,7 @@ public class MapActivity extends BaseActivity
final AlertDialog alertDialog = alertDialogBuilderUserInput.create();
EditText modalUserInput = view.findViewById(R.id.feedback_input);
EditText modalUserInput = view.findViewById(R.id.manual_input);
alertDialog.setOnShowListener(dialogInterface -> {
Button sendButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
@ -365,7 +357,7 @@ public class MapActivity extends BaseActivity
private void sendLocation(String body, LatLng latLng) {
PredefinedStatusesService predefinedStatusesService = ApiClient.getClient(getApplicationContext()).create(PredefinedStatusesService.class);
PredefinedCoordinatesService predefinedCoordinatesService = ApiClient.getClient(getApplicationContext()).create(PredefinedCoordinatesService.class);
PredefinedCoordViewModel droppedMarkercoordinate = new PredefinedCoordViewModel(
latLng.getLatitude(),
@ -379,7 +371,7 @@ public class MapActivity extends BaseActivity
CompositeDisposable disposable = new CompositeDisposable();
disposable.add(
predefinedStatusesService.postUserPredefinedCoord(PrefUtils.getUserId(getApplicationContext()), droppedMarkercoordinate)
predefinedCoordinatesService.postUserPredefinedCoord(PrefUtils.getUserId(getApplicationContext()), droppedMarkercoordinate)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(this::SaveCurrentManualLocation, this::handleError)
@ -603,7 +595,6 @@ public class MapActivity extends BaseActivity
}
}
// Add the mapView lifecycle to the activity's lifecycle methods
@Override
public void onResume() {
super.onResume();
@ -615,6 +606,7 @@ public class MapActivity extends BaseActivity
protected void onStart() {
super.onStart();
mapView.onStart();
shouldFetchNewCoords = true;
}
@Override
@ -708,7 +700,7 @@ public class MapActivity extends BaseActivity
}));
}
private void filterMarkers(List<User> users) {
public void filterMarkers(List<User> users) {
restoreMapMarkers();
Icon markedMarker = IconFactory.getInstance(MapActivity.this).fromResource(R.drawable.search_marker);

View File

@ -1,7 +1,9 @@
package com.uam.wmi.findmytutor.activity;
import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.FragmentTransaction;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.ListPreference;
@ -9,6 +11,7 @@ import android.preference.Preference;
import android.preference.PreferenceCategory;
import android.preference.PreferenceFragment;
import android.preference.SwitchPreference;
import android.support.annotation.NonNull;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@ -19,17 +22,21 @@ import com.annimon.stream.IntPair;
import com.annimon.stream.Stream;
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
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.network.ApiClient;
import com.uam.wmi.findmytutor.service.PredefinedCoordinatesService;
import com.uam.wmi.findmytutor.service.PredefinedStatusesService;
import com.uam.wmi.findmytutor.utils.Const;
import com.uam.wmi.findmytutor.utils.EnableSharingDialog;
import com.uam.wmi.findmytutor.utils.PrefUtils;
import com.uam.wmi.findmytutor.utils.RestApiHelper;
import com.uam.wmi.findmytutor.utils.RightButtonPreference;
import com.uam.wmi.findmytutor.utils.SharingLevel;
import org.apache.commons.collections4.BidiMap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
@ -39,25 +46,34 @@ import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.observers.DisposableSingleObserver;
import io.reactivex.schedulers.Schedulers;
import okhttp3.ResponseBody;
import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext;
public class SharingFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
protected SwitchPreference locationSharing;
protected SwitchPreference statusSwitch;
protected Preference locationMode;
protected ListPreference manualLocationList;
protected PreferenceCategory preferenceCategory;
protected RightButtonPreference manualLocationButton;
protected RightButtonPreference removeManualLocation;
protected RightButtonPreference removeManualStatus;
protected Preference manualStatus;
protected ListPreference statusList;
private HashMap<String,String> locationMap;
private ArrayList <String> locationUUIDs;
protected List<PredefinedCoordViewModel> predefinedCoordsList = new ArrayList<>();
private HashMap<Integer, String> locationLevelMapping;
private HashMap<Integer, String> statusMapping;
private PredefinedStatusesService statusesService;
private PredefinedCoordinatesService locationService;
private CompositeDisposable disposable;
private AlertDialog.Builder builder;
private String[] statusesArray;
private boolean statusSwitchFlag;
private ArrayList<String> predefinedLocationsList;
public static SharingFragment newInstance() {
public static SharingFragment newInstance() {
return new SharingFragment();
}
@ -69,7 +85,13 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
.subscribeWith(new DisposableSingleObserver<List<String>>() {
@Override
public void onSuccess(List<String> strings) {
String[] statusesArray = strings.toArray(new String[strings.size()]);
statusesArray = strings.toArray(new String[strings.size()]);
if(strings.isEmpty()){
disableStatusPreferences();
}else{
enableStatusPreferences();
}
// Log.d("STATUSES",Integer.toString(statusesArray.length ));
setListPreferenceData(statusList, statusesArray, null);
}
@ -82,20 +104,47 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
}
void getLocations(CompositeDisposable disposable) {
disposable.add(statusesService.getUserPredefinedCoords(PrefUtils.getUserId(getApplicationContext()))
disposable.add(locationService.getUserPredefinedCoords(PrefUtils.getUserId(getApplicationContext()))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribeWith(new DisposableSingleObserver<List<PredefinedCoordViewModel>>() {
@Override
public void onSuccess(List<PredefinedCoordViewModel> coords) {
String currentCoordId = PrefUtils.getCurrentManualLocation(getApplicationContext());
List<String> predefinedLocationsNames = Stream.of(coords).map(PredefinedCoordViewModel::getName).toList();
String currentCoordId = PrefUtils.getCurrentManualLocation(getApplicationContext());
locationMap = new HashMap<String,String>();
locationUUIDs = new ArrayList<String>();
for (PredefinedCoordViewModel i : coords) locationMap.put(i.getPredefinedCoordinateId(),i.getName());
for (PredefinedCoordViewModel i : coords) locationUUIDs.add(i.getPredefinedCoordinateId());
List<String> predefinedLocationsNames = Stream.of(coords).map(PredefinedCoordViewModel::getName).toList();
List<String> predefinedLocationsUUIDs = Stream.of(coords).map(PredefinedCoordViewModel::getPredefinedCoordinateId).toList();
predefinedCoordsList.addAll(coords);
String[] stringnames = predefinedLocationsNames.toArray(new String[0]);
predefinedLocationsList = new ArrayList<>(Arrays.asList(stringnames));
if (!PrefUtils.getLocationLevel(getApplicationContext()).equals("manual")) {
preferenceCategory.removePreference(manualLocationList);
preferenceCategory.removePreference(removeManualLocation);
preferenceCategory.removePreference(manualLocationButton);
}else{
if(predefinedCoordsList.isEmpty()){
locationSharing.setEnabled(false);
locationSharing.setChecked(false);
PrefUtils.disableSharing(getApplicationContext());
((MapActivity) getActivity()).handleBackgroundTaskLifeCycle();
removeManualLocation.setEnabled(false);
manualLocationList.setEnabled(false);
manualLocationList.setSummary("");
}else{
manualLocationList.setEnabled(true);
manualLocationList.setSummary(PrefUtils.getCurrentManualLocationName(getApplicationContext()));
removeManualLocation.setEnabled(true);
locationSharing.setEnabled(true);
}
}
List<Integer> activesId = Stream.of(coords).indexed()
.filter(v -> v.getSecond().getPredefinedCoordinateId().equals(currentCoordId)).map(IntPair::getFirst).toList();
@ -105,29 +154,39 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
else {
setListPreferenceData(manualLocationList, stringnames, activesId.get(0));
}
}
@Override
public void onError(Throwable e) {
Toast.makeText(getApplicationContext(), R.string.error_location_fetch, Toast.LENGTH_SHORT).show();
}
}));
}
@SuppressLint("ResourceType")
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.layout.pref_sharing);
addPreferencesFromResource(R.xml.pref_sharing);
locationSharing = (SwitchPreference) findPreference("key_sharing_enabled");
statusSwitch = (SwitchPreference) findPreference("key_status_enabled");
locationMode = findPreference("key_location_level");
preferenceCategory = (PreferenceCategory) findPreference("category_sharing");
manualLocationList = (ListPreference) findPreference("key_manual_location_value");
manualLocationButton = (RightButtonPreference) findPreference("manual_location_button");
removeManualLocation = (RightButtonPreference) findPreference("remove_manual_location");
builder = new AlertDialog.Builder(getActivity());
removeManualStatus = (RightButtonPreference) findPreference("remove_manual_status");
manualStatus = findPreference("key_manual_status");
statusList = (ListPreference) findPreference("key_status_value");
statusesService = ApiClient.getClient(getApplicationContext()).create(PredefinedStatusesService.class);
statusesService = ApiClient.getClient(getApplicationContext()).create(PredefinedStatusesService.class);
locationService = ApiClient.getClient(getApplicationContext()).create(PredefinedCoordinatesService.class);
disposable = new CompositeDisposable();
statusesArray = new String[0];
predefinedLocationsList = new ArrayList<String>();
getStatuses(disposable);
getLocations(disposable);
locationLevelMapping = new HashMap<Integer, String>();
@ -153,28 +212,33 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
/** Sharing level list **/
locationMode.setOnPreferenceChangeListener((preference, newValue) -> {
((MapActivity) getActivity()).stopBackgroundLocalizationTask();
((MapActivity) getActivity()).startBackgroundLocalizationTask();
PrefUtils.storeLocationMode(getApplicationContext(), locationLevelMapping.get(Integer.parseInt((String) newValue)));
if (PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.MANUAL.toString())) {
if (!predefinedCoordsList.isEmpty()) {
preferenceCategory.addPreference(manualLocationList);
preferenceCategory.addPreference(manualLocationList);
preferenceCategory.addPreference(removeManualLocation);
}else{
locationSharing.setEnabled(false);
locationSharing.setChecked(false);
PrefUtils.disableSharing(getApplicationContext());
((MapActivity) getActivity()).handleBackgroundTaskLifeCycle();
}
preferenceCategory.addPreference(manualLocationButton);
} else {
locationSharing.setEnabled(true);
preferenceCategory.removePreference(manualLocationList);
preferenceCategory.removePreference(manualLocationButton);
preferenceCategory.removePreference(removeManualLocation);
}
return true;
});
/** Manual location category hiding when location level is != manual **/
if (!PrefUtils.getLocationLevel(getApplicationContext()).equals("manual")) {
preferenceCategory.removePreference(manualLocationList);
preferenceCategory.removePreference(manualLocationButton);
}
/** Custom manual location list change listener **/
manualLocationList.setOnPreferenceChangeListener((preference, newValue) -> {
@ -199,6 +263,7 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
/** Button 'choose from map' button listener **/
manualLocationButton.setOnPreferenceChangeListener((preference, o) -> {
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
@ -206,7 +271,9 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
fragmentTransaction.commit();
return true;
});
statusSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
return true;
});
/** Status list change listener **/
statusList.setOnPreferenceChangeListener((preference, newValue) -> {
ListPreference lp = (ListPreference) preference;
@ -216,7 +283,7 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
return true;
});
/** Custom status list change listener **/
/** Custom status edittext change listener **/
manualStatus.setOnPreferenceChangeListener((preference, newValue) -> {
disposable.add(statusesService.postUserPredefinedStatus(PrefUtils.getUserId(getApplicationContext()), (String) newValue)
@ -226,6 +293,40 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
return true;
});
removeManualStatus.setOnPreferenceChangeListener((preference, newValue) -> {
showRemoveDialog(statusList.getEntries(),"status");
return true;
});
removeManualLocation.setOnPreferenceChangeListener(((preference, newValue) -> {
showRemoveDialog(manualLocationList.getEntries(),"location");
return true;
}));
}
public void showRemoveDialog(CharSequence[] entries, String service){
boolean [] checked = new boolean[entries.length];
ArrayList<String> tobeDeleted = new ArrayList<String>();
// Log.d("sharingDialog", "no to siup");
builder.setPositiveButton("DELETE", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
for (int i=0; i< entries.length; i++){
if(checked[i] == true) {
tobeDeleted.add((String) entries[i]);
}
}
removeEntries(service,tobeDeleted);
// Log.d("MANAGE-PREF",tobeDeleted.toString());
}
});
builder.setMultiChoiceItems(entries, checked, new DialogInterface.OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
}
});
builder.create().show();
}
@Override
@ -236,6 +337,36 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
return view;
}
protected void removeEntries(String service, ArrayList<String> toBeDeleted){
// Log.d("MANAGE-PREF", toBeDeleted.toString());
if(service.equals("status")){
for (String uuid:toBeDeleted) {
disposable.add(statusesService.deleteUserPredefinedStatus(PrefUtils.getUserId(getApplicationContext()), uuid)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(this::handleDeleteStatuses, this::handleError));
}
}else {
ArrayList<String> uuidsToBeDeleted = new ArrayList<String>();
for (String name:toBeDeleted) {
for (String uuid:locationUUIDs) {
if(locationMap.get(uuid).equals(name)){
uuidsToBeDeleted.add(uuid);
}
}
}
for (String uuid : uuidsToBeDeleted) {
// predefinedCoordsList.removeIf(x -> x.getPredefinedCoordinateId().equals(uuid));
predefinedCoordsList.removeAll(Stream.of(predefinedCoordsList).filter(x -> x.getPredefinedCoordinateId().equals(uuid)).toList());
disposable.add(locationService.deleteUserPredefinedCoord(PrefUtils.getUserId(getApplicationContext()), uuid)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(this::handleDeleteLocations, this::handleError));
}
}
}
protected void setListPreferenceData(ListPreference lp, String[] entries, Integer activeId) {
try {
@ -261,10 +392,15 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
;
private void handleResponse(List<String> resp) {
if(resp.size() == 1){
enableStatusPreferences();
if(PrefUtils.isStatusEnabled(getApplicationContext()) == false){
PrefUtils.enableStatus(getApplicationContext());
statusSwitch.setChecked(true);
}
}
String[] statusesArray = resp.toArray(new String[resp.size()]);
setListPreferenceData(statusList, statusesArray, resp.size() - 1);
statusList.setValueIndex(resp.size() - 1);
PrefUtils.storeStatus(getApplicationContext(), resp.get(resp.size() - 1));
statusList.setSummary(PrefUtils.getUserStatus(getApplicationContext()));
@ -281,6 +417,73 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
"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 handleDeleteLocations(List<PredefinedCoordViewModel> resp){
getLocations(disposable);
String currentEntry = PrefUtils.getCurrentManualLocation(getApplicationContext());
if(resp.isEmpty()){
disableManualLocationPreferences();
}else{
if(!Stream.of(resp).filter(x -> x.getName().equals(currentEntry)).toList().isEmpty())
{
for (PredefinedCoordViewModel location: resp) {
if(location.getName().equals(currentEntry)){
manualLocationList.setValueIndex(resp.indexOf(location));
break;
}
}
}else{
manualLocationList.setValueIndex(0);
manualLocationList.setSummary(resp.get(0).getName());
//todo czy na pewno w shared pref sa dobre wartosci
}
}
}
private void disableStatusPreferences(){
removeManualStatus.setEnabled(false);
statusList.setEnabled(false);
statusSwitch.setEnabled(false);
statusList.setSummary("");
PrefUtils.disableStatus(getApplicationContext());
}
private void enableStatusPreferences(){
removeManualStatus.setEnabled(true);
statusList.setEnabled(true);
statusSwitch.setEnabled(true);
statusList.setSummary(PrefUtils.getUserStatus(getApplicationContext()));
}
private void disableManualLocationPreferences(){
removeManualLocation.setEnabled(false);
manualLocationList.setEnabled(false);
manualLocationList.setSummary("");
locationSharing.setChecked(false);
locationSharing.setEnabled(false);
PrefUtils.disableSharing(getApplicationContext());
((MapActivity) getActivity()).handleBackgroundTaskLifeCycle();
}
private void enableManualLocationPreferences(){
removeManualLocation.setEnabled(true);
manualLocationList.setEnabled(true);
}
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
@ -300,4 +503,10 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
getPreferenceManager().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
super.onPause();
}
@Override
public void onDestroy() {
super.onDestroy();
disposable.dispose();
}
}

View File

@ -0,0 +1,19 @@
package com.uam.wmi.findmytutor.activity;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import com.uam.wmi.findmytutor.R;
public abstract class SpecialList extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(getContentViewId());
}
abstract int getContentViewId();
}

View File

@ -29,6 +29,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import butterknife.ButterKnife;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.observers.DisposableCompletableObserver;
@ -61,9 +62,10 @@ public class TutorTab extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
setContentView(R.layout.content_tutor_tab);
ButterKnife.bind(this);
userName = findViewById(R.id.userName);
userNote = (TextInputEditText) findViewById(R.id.userNote);
@ -134,7 +136,12 @@ public class TutorTab extends AppCompatActivity {
@Override
public void onError(Throwable e) {
int code = ((HttpException) e).response().code();
int code = 0;
if (e instanceof HttpException) {
code = ((HttpException) e).response().code();
}
if( code == 404){
ifTutorTabExists = false;
dutyHoursAdapter = new DutyHoursAdapter(getApplicationContext(),new ArrayList<DutyHourViewModel>());
@ -144,7 +151,6 @@ public class TutorTab extends AppCompatActivity {
showError(e);
}
}));
}
private void addEmptyDuty(DutyHoursAdapter adapter){

View File

@ -0,0 +1,46 @@
package com.uam.wmi.findmytutor.activity;
//import android.app.Fragment;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.support.v4.app.FragmentTabHost;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.uam.wmi.findmytutor.R;
public class TutorsListTab extends Fragment {
private FragmentTabHost mTabHost;
public TutorsListTab() {
}
public static TutorsListTab newInstance() {
return new TutorsListTab();
}
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.tutors_list_tabs, container, false);
mTabHost = rootView.findViewById(android.R.id.tabhost);
mTabHost.setup(getActivity(), getFragmentManager(), R.id.realtabcontent);
mTabHost.addTab(mTabHost.newTabSpec("fragmentb").setIndicator("Fragment B"),
UsersListFragment.class, null);
mTabHost.addTab(mTabHost.newTabSpec("fragmentc").setIndicator("Fragment C"),
UsersListFragment.class, null);
return rootView;
}
}

View File

@ -1,6 +1,8 @@
package com.uam.wmi.findmytutor.activity;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.CoordinatorLayout;
@ -9,27 +11,36 @@ import android.support.v7.app.AlertDialog;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.SearchView;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.ImageSpan;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.annimon.stream.Stream;
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
import com.uam.wmi.findmytutor.R;
import com.uam.wmi.findmytutor.adapters.TutorsListAdapter;
import com.uam.wmi.findmytutor.model.DutyHourViewModel;
import com.uam.wmi.findmytutor.model.TutorTabViewModel;
import com.uam.wmi.findmytutor.model.User;
import com.uam.wmi.findmytutor.network.ApiClient;
import com.uam.wmi.findmytutor.service.TutorTabApi;
import com.uam.wmi.findmytutor.service.UserService;
import com.uam.wmi.findmytutor.utils.InfoHelperUtils;
import com.uam.wmi.findmytutor.utils.MyDividerItemDecoration;
import com.uam.wmi.findmytutor.utils.PrefUtils;
import com.uam.wmi.findmytutor.utils.RecyclerTouchListener;
import com.uam.wmi.findmytutor.utils.RestApiHelper;
@ -59,13 +70,14 @@ public class UsersListFragment extends Fragment {
@BindView(R.id.txt_empty_notes_view)
TextView noNotesView;
private SearchView searchView;
private UserService userService;
private TutorTabApi tutorTabService;
private CompositeDisposable disposable = new CompositeDisposable();
private TutorsListAdapter mAdapter;
private List<User> tutorsList = new ArrayList<>();
private List<User> tutorsFiltered = new ArrayList<>();
private Collator plCollator = Collator.getInstance(Locale.forLanguageTag("pl-PL"));
private Boolean fetchOnlyOnlineUsers = PrefUtils.getShowOnlyOnlineUsers(getApplicationContext());
public UsersListFragment() {
}
@ -75,10 +87,10 @@ public class UsersListFragment extends Fragment {
}
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mAdapter = new TutorsListAdapter(getActivity().getApplicationContext(), tutorsFiltered);
mAdapter = new TutorsListAdapter(getActivity().getApplicationContext(), tutorsList);
View view = inflater.inflate(R.layout.users_list, container, false);
view.setBackgroundColor(getResources().getColor(android.R.color.white));
setHasOptionsMenu(true);
return view;
}
@ -94,6 +106,7 @@ public class UsersListFragment extends Fragment {
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getActivity());
recyclerView.setLayoutManager(mLayoutManager);
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.setVerticalScrollBarEnabled(true);
recyclerView.addItemDecoration(new MyDividerItemDecoration(getActivity(), LinearLayoutManager.VERTICAL, 16));
recyclerView.setAdapter(mAdapter);
@ -103,7 +116,7 @@ public class UsersListFragment extends Fragment {
recyclerView, new RecyclerTouchListener.ClickListener() {
@Override
public void onClick(View view, final int position) {
showNoteDialog(tutorsFiltered.get(position));
showNoteDialog(tutorsList.get(position));
}
@Override
@ -113,12 +126,52 @@ public class UsersListFragment extends Fragment {
}
public void searchUser(String textToSearch) {
tutorsFiltered.clear();
tutorsFiltered.addAll(Stream.of(tutorsList).filter(t ->
t.toSearchAbleString().toLowerCase().contains(textToSearch.toLowerCase())).toList());
mAdapter.notifyDataSetChanged();
@Override
public void onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
try {
menu.findItem(R.id.showOnlineUsersOnly).setChecked(fetchOnlyOnlineUsers);
} catch (Exception e) {
Log.e(TAG, "onPrepareOptionsMenu error");
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
//item.setChecked(fetchOnlyOnlineUsers);
switch (item.getItemId()) {
case R.id.showOnlineUsersOnly:
if (item.isChecked()) {
fetchOnlyOnlineUsers = false;
item.setChecked(false);
} else {
item.setChecked(true);
fetchOnlyOnlineUsers = true;
}
PrefUtils.putShowOnlyOnlineUsers(getApplicationContext(), fetchOnlyOnlineUsers);
fetchAllTutors();
break;
}
return false;
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.users_list_menu, menu);
menu.getItem(0).setChecked(fetchOnlyOnlineUsers);
MenuItem myActionMenuItem = menu.findItem(R.id.action_search);
searchView = (SearchView) myActionMenuItem.getActionView();
super.onCreateOptionsMenu(menu, inflater);
}
public void searchUser(String textToSearch) {
searchTutorInBackend(textToSearch);
}
private void showNoteDialog(final User user) {
@ -132,6 +185,7 @@ public class UsersListFragment extends Fragment {
// User cancelled the dialog
});
TextView userName = view.findViewById(R.id.userName);
ListView userDutyHours = view.findViewById(R.id.userDutyHours);
TextView userDutyHoursTitle = view.findViewById(R.id.userDutyHoursTitle);
@ -140,8 +194,26 @@ public class UsersListFragment extends Fragment {
TextView userEmail = view.findViewById(R.id.userEmail);
TextView department = view.findViewById(R.id.userDepartment);
userName.setText(String.format("%s %s", user.getFirstName(), user.getLastName()));
userName.setText(String.format("%s %s", user.getFirstName(), user.getLastName()));
Drawable image;
if (user.isIsOnline()) {
image = this.getResources().getDrawable(R.drawable.user_list_online);
} else {
image = this.getResources().getDrawable(R.drawable.user_list_offline);
}
if (!user.isIsActive()) {
image = this.getResources().getDrawable(R.drawable.user_list_off);
}
Spannable span = new SpannableString(" " + userName.getText()); // or set your text manually
image.setBounds(0, 0, image.getIntrinsicWidth(), image.getIntrinsicHeight());
ImageSpan imageSpan = new ImageSpan(image);
span.setSpan(imageSpan, 0, 1, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
userName.setText(span);
UsersListFragment usersListFragment = this;
disposable.add(
tutorTabService.apiUsersTutorTabByTutorIdGet(user.getId())
.subscribeOn(Schedulers.io())
@ -149,7 +221,20 @@ public class UsersListFragment extends Fragment {
.subscribeWith(new DisposableSingleObserver<TutorTabViewModel>() {
@Override
public void onSuccess(TutorTabViewModel tutorTabViewModel) {
final AlertDialog alertDialog = alertDialogBuilderUserInput.create();
final AlertDialog alertDialog;
if (((MapActivity) getActivity()).markerUserHash.containsValue(user.getId())) {
alertDialogBuilderUserInput.setPositiveButton(R.string.show_on_map, (dialog, id) -> {
// User cancelled the dialog
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
fragmentTransaction.hide(usersListFragment);
fragmentTransaction.commit();
List<User> list = new ArrayList<User>();
list.add(user);
((MapActivity) getActivity()).filterMarkers(list);
});
}
alertDialog = alertDialogBuilderUserInput.create();
String userNoteText = tutorTabViewModel.getNote();
List<String> dutyHoursList = Stream.of(tutorTabViewModel.getDutyHours())
.map(DutyHourViewModel::getSummary).toList();
@ -185,17 +270,16 @@ public class UsersListFragment extends Fragment {
private void fetchAllTutors() {
disposable.add(
userService.getAllTutors()
(fetchOnlyOnlineUsers ?
userService.getAllActiveTutors() :
userService.getAllOfflineTutors())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.map(tutors -> {
List<User> tutorsList = new ArrayList<>(tutors);
List<User> onlineTutors = Stream.of(tutorsList).filter(User::isIsOnline).toList();
List<User> activeNotOnlineTutors = Stream.of(tutorsList)
.filter(t -> t.isIsActive() && !onlineTutors.contains(t)).toList();
List<User> notActiveTutors = Stream.of(tutorsList)
.filterNot(User::isIsActive).toList();
@ -213,9 +297,7 @@ public class UsersListFragment extends Fragment {
@Override
public void onSuccess(List<User> users) {
tutorsList.clear();
tutorsFiltered.clear();
tutorsList.addAll(users);
tutorsFiltered.addAll(users);
mAdapter.notifyDataSetChanged();
toggleEmptyNotes();
}
@ -228,22 +310,70 @@ public class UsersListFragment extends Fragment {
}
private void searchTutorInBackend(String searchString) {
disposable.add(
userService.searchUser(searchString)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribeWith(new DisposableSingleObserver<List<User>>() {
@Override
public void onSuccess(List<User> users) {
tutorsList.clear();
tutorsList.addAll(users);
mAdapter.notifyDataSetChanged();
}
@Override
public void onError(Throwable e) {
showSearchError(e);
}
}));
}
public void restoreUsersList() {
fetchAllTutors();
}
private int sortByUserName(User t1, User t2) {
return plCollator.compare(t1.getLastName(), t2.getLastName());
}
private void showError(Throwable e) {
String message;
Log.e(TAG, String.valueOf(e));
if (e instanceof HttpException) {
ResponseBody responseBody = ((HttpException) e).response().errorBody();
message = RestApiHelper.getErrorMessage(responseBody);
} else {
message = "Network Error !";
message = getString(R.string.network_err);
}
Snackbar.make(coordinatorLayout, message, Snackbar.LENGTH_LONG)
.show();
createSnackbar(message);
}
private void showSearchError(Throwable e) {
String message;
Log.e(TAG, String.valueOf(e));
if (e instanceof HttpException) {
ResponseBody responseBody = ((HttpException) e).response().errorBody();
message = RestApiHelper.getErrorMessage(responseBody);
} else {
message = getString(R.string.search_null);
}
createSnackbar(message);
}
private void createSnackbar(String msg) {
Snackbar snackbar = Snackbar.make(coordinatorLayout, msg, Snackbar.LENGTH_LONG);
View view = snackbar.getView();
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) view.getLayoutParams();
params.gravity = Gravity.TOP;
view.setLayoutParams(params);
snackbar.show();
}
private void toggleEmptyNotes() {
@ -251,6 +381,11 @@ public class UsersListFragment extends Fragment {
noNotesView.setVisibility(View.GONE);
} else {
noNotesView.setVisibility(View.VISIBLE);
if (fetchOnlyOnlineUsers)
noNotesView.setText(R.string.no_online_users);
else {
noNotesView.setText(R.string.no_offline_users);
}
}
}

View File

@ -0,0 +1,345 @@
package com.uam.wmi.findmytutor.activity;
import android.annotation.SuppressLint;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.Switch;
import android.widget.TextView;
import android.widget.Toast;
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
import com.uam.wmi.findmytutor.R;
import com.uam.wmi.findmytutor.adapters.WhiteListAdapter;
import com.uam.wmi.findmytutor.model.IsUsingListBool;
import com.uam.wmi.findmytutor.model.StudentIdModel;
import com.uam.wmi.findmytutor.model.User;
import com.uam.wmi.findmytutor.network.ApiClient;
import com.uam.wmi.findmytutor.service.UserService;
import com.uam.wmi.findmytutor.utils.MyDividerItemDecoration;
import com.uam.wmi.findmytutor.utils.PrefUtils;
import com.uam.wmi.findmytutor.utils.RecyclerTouchListener;
import com.uam.wmi.findmytutor.utils.RestApiHelper;
import com.uam.wmi.findmytutor.utils.WrapContentLinearLayoutManager;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import butterknife.BindView;
import butterknife.ButterKnife;
import io.reactivex.Observable;
import io.reactivex.ObservableSource;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.functions.Function;
import io.reactivex.observers.DisposableObserver;
import io.reactivex.schedulers.Schedulers;
import okhttp3.ResponseBody;
public class WhiteList extends AppCompatActivity {
private CompositeDisposable disposable = new CompositeDisposable();
private UserService userService;
private boolean didFetched = false;
private String tutorId;
@BindView(R.id.recycler_view_whitelist)
RecyclerView recyclerView;
@BindView(R.id.white_list_empty_text_view)
TextView noNotesView;
@BindView(R.id.switch_whitelist_toggle)
Switch aSwitch;
@BindView(R.id.add_to_white_list_fab)
FloatingActionButton addToWhiteListFab;
private WhiteListAdapter mAdapter;
private Integer prevSize;
private List<User> whitelistedUsers = new ArrayList<>();
private Collator plCollator = Collator.getInstance(Locale.forLanguageTag("pl-PL"));
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
setContentView(R.layout.activity_white_list);
ButterKnife.bind(this);
tutorId = PrefUtils.getUserId(getApplicationContext());
userService = ApiClient.getClient(getApplicationContext())
.create(UserService.class);
if (PrefUtils.isWhiteListing(this)){
aSwitch.setText(getString(R.string.action_white_list) +" ON");
aSwitch.setChecked(true);
handleChangeRequest(true);
}else{
aSwitch.setText(getString(R.string.action_white_list) +" OFF");
aSwitch.setChecked(false);
handleChangeRequest(false);
}
Toolbar toolbar = findViewById(R.id.toolbar);
toolbar.setTitle(getString(R.string.activity_title_whitelist));
setSupportActionBar(toolbar);
mAdapter = new WhiteListAdapter(this, whitelistedUsers);
recyclerView.setLayoutManager(new WrapContentLinearLayoutManager(getApplicationContext()));
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.addItemDecoration(new MyDividerItemDecoration(this, LinearLayoutManager.VERTICAL, 16));
recyclerView.setAdapter(mAdapter);
/**
* On long press on RecyclerView item, open alert dialog
* with options to choose
* Edit and Delete
* */
recyclerView.addOnItemTouchListener(new RecyclerTouchListener(this,
recyclerView, new RecyclerTouchListener.ClickListener() {
@Override
public void onClick(View view, final int position) {
}
@Override
public void onLongClick(View view, int position) {
}
}));
addToWhiteListFab.setOnClickListener(this::showFabDialog);
fetchWhiteListedUsers();
handleSwitch();
}
private Observable<List<String>> getListOfWhitelistedUsers(String userId) {
return userService.getTutorWhitelistedByID(userId)
.toObservable()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
private Observable<User> getUserObservable(String userId) {
return userService
.getUserById(userId)
.toObservable()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
private void fetchWhiteListedUsers() {
prevSize = whitelistedUsers.size();
whitelistedUsers.clear();
disposable.add(getListOfWhitelistedUsers(tutorId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.flatMap((Function<List<String>, Observable<String>>) Observable::fromIterable)
.flatMap((Function<String, ObservableSource<User>>) this::getUserObservable)
.subscribeWith(new DisposableObserver<User>() {
@Override
public void onNext(User user) {
whitelistedUsers.add(user);
}
@Override
public void onError(Throwable e) {
showError(e);
}
@Override
public void onComplete() {
Collections.sort(whitelistedUsers, (a, b) -> sortByUserName(a,b));
refreshUI();
}
}));
}
private void refreshUI(){
toggleEmptyNotes();
mAdapter.notifyItemRangeInserted(prevSize, whitelistedUsers.size() - prevSize);
mAdapter.notifyDataSetChanged();
}
private int sortByUserName(User t1, User t2) {
return plCollator.compare(t1.getLastName(), t2.getLastName());
}
private void showFabDialog(View v){
LayoutInflater layoutInflaterAndroid = LayoutInflater.from(getApplicationContext());
@SuppressLint("InflateParams") View view = layoutInflaterAndroid.inflate(R.layout.white_list_fab_modal, null);
AlertDialog.Builder alertDialogBuilderUserInput = new AlertDialog.Builder(this);
alertDialogBuilderUserInput.setView(view).setPositiveButton(getApplicationContext().getString(R.string.modal_location_send), null);
alertDialogBuilderUserInput
.setPositiveButton(R.string.add, null)
.setNegativeButton(R.string.cancel, null);
final AlertDialog alertDialog = alertDialogBuilderUserInput.create();
alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
EditText modalUserInput = view.findViewById(R.id.white_list_modal_input);
alertDialog.setOnShowListener(dialogInterface -> {
Button sendButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
Button dismissButton = alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE);
dismissButton.setOnClickListener(view1 -> alertDialog.dismiss());
sendButton.setOnClickListener(view1 -> {
String body = modalUserInput.getText().toString();
if (TextUtils.isEmpty(body)) {
Toast.makeText(getApplicationContext(), R.string.can_not_be_empty, Toast.LENGTH_SHORT).show();
modalUserInput.requestFocus();
} else {
sendUserToWhitelist(body);
alertDialog.dismiss();
}
});
});
alertDialog.show();
}
private void sendUserToWhitelist(String body) {
StudentIdModel studentIdModel = new StudentIdModel(body);
disposable.add(
userService.addStudentToWhitelist(tutorId, studentIdModel)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(this::handleAddUser,this::showError)
);
}
private void handleAddUser(User user) {
Toast.makeText(this, R.string.add_user_to_list, Snackbar.LENGTH_LONG).show();
fetchWhiteListedUsers();
}
private void showError(Throwable e) {
String message;
if (e instanceof HttpException) {
ResponseBody responseBody = ((HttpException) e).response().errorBody();
message = RestApiHelper.getErrorMessage(responseBody);
if (((HttpException) e).response().code() == 404) {
message = getString(R.string.no_such_a_user);
}
} else {
message = "Network Error !";
}
Log.e("ERR",message);
Toast.makeText(this, message, Snackbar.LENGTH_LONG).show();
}
private void toggleEmptyNotes() {
if (didFetched && whitelistedUsers.size() == 0) {
noNotesView.setText(R.string.list_is_empty);
noNotesView.setVisibility(View.VISIBLE);
}else if (whitelistedUsers.size() > 0) {
noNotesView.setVisibility(View.GONE);
} else {
noNotesView.setText(getString(R.string.loading));
noNotesView.setVisibility(View.VISIBLE);
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId()==R.id.action_whitelist_info_popup){
int layoutID = R.layout.info_popup_whitelist;
View popupView = getLayoutInflater().inflate(layoutID,null);
PopupWindow popupWindow = new PopupWindow(popupView,
LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
// If the PopupWindow should be focusable
popupWindow.setFocusable(true);
// If you need the PopupWindow to dismiss when when touched outside
popupWindow.setBackgroundDrawable(new ColorDrawable());
// Get the View's(the one that was clicked in the Fragment) location
View anchorView= getWindow().getDecorView().findViewById(android.R.id.content);
popupWindow.showAtLocation(anchorView,Gravity.TOP|Gravity.END, 0, 0);
}
return super.onOptionsItemSelected(item);
}
private void handleSwitch(){
aSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (isChecked){
aSwitch.setText(getString(R.string.action_white_list) + " "+ getString(R.string.on));
handleChangeRequest(true);
PrefUtils.useWhitelist(this, true);
}else {
aSwitch.setText(getString(R.string.action_white_list) + " "+getString(R.string.off));
handleChangeRequest(false);
PrefUtils.useWhitelist(this, false);
}
});
}
private void handleChangeRequest(boolean value){
IsUsingListBool isUsingListBool = new IsUsingListBool();
isUsingListBool.setIsUsing(value);
disposable.add(
userService.setTutorWhitelist(tutorId, isUsingListBool)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(()->{
},this::showError)
);
}
@Override
public void onResume() {
super.onResume();
}
@Override
public void onPause() {
super.onPause();
}
@Override
public void onStop() {
super.onStop();
}
@Override
public void onDestroy() {
super.onDestroy();
disposable.dispose();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_white_list, menu);
return true;
}
}

View File

@ -0,0 +1,119 @@
package com.uam.wmi.findmytutor.adapters;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.design.widget.Snackbar;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
import com.uam.wmi.findmytutor.R;
import com.uam.wmi.findmytutor.model.StudentIdModel;
import com.uam.wmi.findmytutor.model.User;
import com.uam.wmi.findmytutor.network.ApiClient;
import com.uam.wmi.findmytutor.service.UserService;
import com.uam.wmi.findmytutor.utils.PrefUtils;
import com.uam.wmi.findmytutor.utils.RestApiHelper;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.schedulers.Schedulers;
import okhttp3.ResponseBody;
import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext;
public class BlackListAdapter extends RecyclerView.Adapter<BlackListAdapter.MyViewHolder> {
private Context context;
private List<User> tutorsList;
private CompositeDisposable disposable = new CompositeDisposable();
private UserService userService;
public BlackListAdapter(Context context, List<User> tutors) {
this.context = context;
this.tutorsList = tutors;
}
@NonNull
@Override
public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
userService = ApiClient.getClient(getApplicationContext())
.create(UserService.class);
View itemView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.black_list_row, parent, false);
return new MyViewHolder(itemView);
}
@Override
public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
Drawable image = null;
User tutor = tutorsList.get(position);
holder.firstName.setText(tutor.getFirstName() + " " + tutor.getLastName());
holder.lastName.setText("Index: " + tutor.getLdapLogin() + " Email: " + tutor.getEmail());
//"s416196"
holder.imageButton.setOnClickListener(l ->{
StudentIdModel studentIdModel = new StudentIdModel(tutor.getLdapLogin());
String tutorId = PrefUtils.getUserId(getApplicationContext());
disposable.add(
userService.removeStudentFromBlacklist(tutorId, studentIdModel)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(()->{
Toast.makeText(getApplicationContext(), R.string.user_removed, Toast.LENGTH_SHORT).show();
tutorsList.remove(position);
notifyDataSetChanged();
},this::showError)
);
});
}
@Override
public int getItemCount() {
return tutorsList.size();
}
class MyViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.firstName)
TextView firstName;
@BindView(R.id.lastName)
TextView lastName;
@BindView(R.id.removeUserImageButton)
ImageButton imageButton;
MyViewHolder(View view) {
super(view);
ButterKnife.bind(this, view);
}
}
private void showError(Throwable e) {
String message;
if (e instanceof HttpException) {
ResponseBody responseBody = ((HttpException) e).response().errorBody();
message = RestApiHelper.getErrorMessage(responseBody);
} else {
message = "Network Error !";
}
Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show();
}
}

View File

@ -11,12 +11,10 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.TextView;
import com.annimon.stream.Collectors;
import com.annimon.stream.Stream;
import com.uam.wmi.findmytutor.R;
import com.uam.wmi.findmytutor.model.DutyHourViewModel;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
@ -29,7 +27,7 @@ public class DutyHoursAdapter extends RecyclerView.Adapter<DutyHoursAdapter.MyV
public DutyHoursAdapter(Context context, List<DutyHourViewModel> hours) {
this.context = context;
this.hours = new ArrayList<DutyHourViewModel>(hours);
this.hours = new ArrayList<>(hours);
}
@ -114,16 +112,16 @@ public class DutyHoursAdapter extends RecyclerView.Adapter<DutyHoursAdapter.MyV
@Override
public void onClick(View v) {
try{
Log.d("DutyIndex bf rm size",Integer.toString(getItemCount()));
Log.d("DutyIndex bf rm pos",Integer.toString(holder.getLayoutPosition()));
// Log.d("DutyIndex bf rm size",Integer.toString(getItemCount()));
// Log.d("DutyIndex bf rm pos",Integer.toString(holder.getLayoutPosition()));
removeDuty(holder.getLayoutPosition());
Log.d("DutyIndex af rm pos",Integer.toString(holder.getLayoutPosition()));
// Log.d("DutyIndex af rm pos",Integer.toString(holder.getLayoutPosition()));
}catch(Error e){
Log.e("DutyIndex error",e.getMessage());
Log.e("DutyIndex size",Integer.toString(getItemCount()));
Log.e("DutyIndex pos",Integer.toString(holder.getAdapterPosition()));
// Log.e("DutyIndex error",e.getMessage());
// Log.e("DutyIndex size",Integer.toString(getItemCount()));
// Log.e("DutyIndex pos",Integer.toString(holder.getAdapterPosition()));
}

View File

@ -37,7 +37,7 @@ public class TutorsListAdapter extends RecyclerView.Adapter<TutorsListAdapter.My
}
@Override
public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
Drawable image = null;
User tutor = tutorsList.get(position);

View File

@ -0,0 +1,117 @@
package com.uam.wmi.findmytutor.adapters;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
import com.uam.wmi.findmytutor.R;
import com.uam.wmi.findmytutor.model.StudentIdModel;
import com.uam.wmi.findmytutor.model.User;
import com.uam.wmi.findmytutor.network.ApiClient;
import com.uam.wmi.findmytutor.service.UserService;
import com.uam.wmi.findmytutor.utils.PrefUtils;
import com.uam.wmi.findmytutor.utils.RestApiHelper;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.schedulers.Schedulers;
import okhttp3.ResponseBody;
import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext;
public class WhiteListAdapter extends RecyclerView.Adapter<WhiteListAdapter.MyViewHolder> {
private Context context;
private List<User> tutorsList;
private CompositeDisposable disposable = new CompositeDisposable();
private UserService userService;
public WhiteListAdapter(Context context, List<User> tutors) {
this.context = context;
this.tutorsList = tutors;
}
@NonNull
@Override
public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
userService = ApiClient.getClient(getApplicationContext())
.create(UserService.class);
View itemView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.white_list_row, parent, false);
return new MyViewHolder(itemView);
}
@Override
public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
Drawable image = null;
User tutor = tutorsList.get(position);
holder.firstName.setText(tutor.getFirstName() + " " + tutor.getLastName());
holder.lastName.setText("Index: " + tutor.getLdapLogin() + " Email: " + tutor.getEmail());
//""
holder.imageButton.setOnClickListener(l ->{
StudentIdModel studentIdModel = new StudentIdModel(tutor.getLdapLogin());
String tutorId = PrefUtils.getUserId(getApplicationContext());
disposable.add(
userService.removeStudentFromWhitelist(tutorId, studentIdModel)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(()->{
Toast.makeText(getApplicationContext(), R.string.user_removed, Toast.LENGTH_SHORT).show();
tutorsList.remove(position);
notifyDataSetChanged();
},this::showError)
);
});
}
@Override
public int getItemCount() {
return tutorsList.size();
}
class MyViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.firstName)
TextView firstName;
@BindView(R.id.lastName)
TextView lastName;
@BindView(R.id.removeUserImageButton)
ImageButton imageButton;
MyViewHolder(View view) {
super(view);
ButterKnife.bind(this, view);
}
}
private void showError(Throwable e) {
String message;
if (e instanceof HttpException) {
ResponseBody responseBody = ((HttpException) e).response().errorBody();
message = RestApiHelper.getErrorMessage(responseBody);
} else {
message = "Network Error !";
}
Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show();
}
}

View File

@ -18,6 +18,15 @@ public class StudentIdModel extends BaseResponse{
@SerializedName("ldapLogin")
private String ldapLogin = null;
/**
*
* @param str
*/
public StudentIdModel(String str){
// this.studentId = str;
this.ldapLogin = str;
}
public StudentIdModel studentId(String studentId) {
this.studentId = studentId;
return this;

View File

@ -11,12 +11,13 @@ import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.support.annotation.RequiresApi;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.NotificationCompat;
@ -24,8 +25,10 @@ import android.util.Log;
import com.annimon.stream.Stream;
import com.google.android.gms.location.FusedLocationProviderClient;
import com.google.android.gms.location.LocationCallback;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationResult;
import com.google.android.gms.location.LocationServices;
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
import com.mapbox.geojson.Point;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.uam.wmi.findmytutor.model.Coordinate;
@ -33,21 +36,17 @@ import com.uam.wmi.findmytutor.network.ApiClient;
import com.uam.wmi.findmytutor.utils.ApproximatedLocalization;
import com.uam.wmi.findmytutor.utils.MapUtils;
import com.uam.wmi.findmytutor.utils.PrefUtils;
import com.uam.wmi.findmytutor.utils.RestApiHelper;
import com.uam.wmi.findmytutor.utils.SharingLevel;
import org.apache.commons.collections4.queue.CircularFifoQueue;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.observers.DisposableCompletableObserver;
import io.reactivex.observers.DisposableSingleObserver;
import io.reactivex.schedulers.Schedulers;
import okhttp3.ResponseBody;
import static com.uam.wmi.findmytutor.utils.Const.offlineBackgroundLocationInterval;
import static com.uam.wmi.findmytutor.utils.Const.onlineBackgroundLocationInterval;
@ -60,32 +59,33 @@ import static java.lang.String.valueOf;
public class BackgroundLocalizationService extends Service {
private static final String TAG = "MyLocationService";
private static final float LOCATION_DISTANCE = 1f;
private static long notify_interval = onlineBackgroundLocationInterval;
private static long notify_interval_inside_building = onlineBackgroundLocationInterval;
private static long notify_interval_outside_building = offlineBackgroundLocationInterval;
private static int coordinatesHistoryLength = 5;
private static final Long LOCATION_INTERVAL = notify_interval;
private static Integer notify_interval = onlineBackgroundLocationInterval;
private static Integer notify_interval_inside_building = onlineBackgroundLocationInterval;
private static Integer notify_interval_outside_building = offlineBackgroundLocationInterval;
private static int coordinatesHistoryLength = 10;
private Boolean highAccuracyMode;
private Location mLastLocation;
private Boolean stopService = false;
private ArrayList<String> providers = new ArrayList<String>();
private LocationListener[] mLocationListeners;
private CircularFifoQueue<Location> coordinatesHistory = new CircularFifoQueue<Location>(coordinatesHistoryLength);
private LocationManager mLocationManager = null;
private Handler mHandler = new Handler();
private Runnable mStatusChecker;
private FusedLocationProviderClient mFusedLocationClient;
private Location fakeLoc = null;
private LocationRequest mLocationRequest;
private Location mCurrentLocation;
private LocationCallback mLocationCallback;
private LocationListener mLocationListener;
public BackgroundLocalizationService() {
providers.add(LocationManager.GPS_PROVIDER);
providers.add(LocationManager.NETWORK_PROVIDER);
providers.add(LocationManager.PASSIVE_PROVIDER);
fakeLoc = new Location("");
mLocationListeners = new LocationListener[]{
new LocationListener(LocationManager.GPS_PROVIDER),
new LocationListener(LocationManager.NETWORK_PROVIDER),
new LocationListener(LocationManager.PASSIVE_PROVIDER)
};
fakeLoc.setLatitude(0);
fakeLoc.setLongitude(0);
fakeLoc.setAltitude(0);
}
@Override
@ -100,7 +100,9 @@ public class BackgroundLocalizationService extends Service {
if (intent != null) {
stopService = intent.getBooleanExtra("request_stop", false);
notify_interval = intent.getIntExtra("notify_interval", onlineBackgroundLocationInterval);
}
if (stopService) {
storeBackgroundLocationStatus(getApplication(), false);
stopForeground(true);
@ -111,6 +113,20 @@ public class BackgroundLocalizationService extends Service {
return START_STICKY;
}
private void createLocationCallback() {
mLocationCallback = new LocationCallback() {
@Override
public void onLocationResult(LocationResult locationResult) {
super.onLocationResult(locationResult);
if (locationResult != null) {
mCurrentLocation = locationResult.getLastLocation();
sendCoordinateToBackend(mCurrentLocation);
changeBackgroundMode();
}
}
};
}
@Override
public void onCreate() {
Log.e(TAG, "onCreate");
@ -124,35 +140,13 @@ public class BackgroundLocalizationService extends Service {
startForeground(1001, notification);
}
mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this);
initializeLocationManager();
Integer providerIndex = 0;
for (LocationListener listener : mLocationListeners) {
try {
mLocationManager.requestLocationUpdates(
providers.get(providerIndex),
LOCATION_INTERVAL,
LOCATION_DISTANCE,
listener
);
} catch (java.lang.SecurityException ex) {
Log.i(TAG, "fail to request location update, ignore", ex);
} catch (IllegalArgumentException ex) {
Log.d(TAG, "network provider does not exist, " + ex.getMessage());
}
providerIndex++;
}
if (!stopService) {
if (!stopService && !PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.MANUAL.toString())) {
createFusedLocationClient();
} else if (!stopService &&
PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.MANUAL.toString())) {
mStatusChecker = () -> {
try {
getLocalizationFromListeners();
changeBackgroundMode();
sendCoordinateToBackend(fakeLoc);
} finally {
mHandler.postDelayed(mStatusChecker, notify_interval);
}
@ -162,19 +156,52 @@ public class BackgroundLocalizationService extends Service {
}
}
private void createFusedLocationClient() {
Integer saveMode = Long.valueOf(notify_interval).compareTo(Long.valueOf(offlineBackgroundLocationInterval));
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return;
}
mLocationRequest = new LocationRequest();
if (saveMode != 0) {
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
} else {
mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
}
mLocationRequest.setFastestInterval(notify_interval);
mLocationRequest.setInterval(notify_interval);
createLocationCallback();
if (!stopService) {
mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this);
mFusedLocationClient.requestLocationUpdates(mLocationRequest,
mLocationCallback, Looper.getMainLooper());
}
}
private void changeBackgroundMode() {
if (coordinatesHistory.size() > 4) {
Boolean shouldExtendTimeInterval = Stream.of(coordinatesHistory)
.map(MapUtils::checkIfCoordinateIsValid).takeWhile(s -> !s).toList().size() == coordinatesHistory.size();
Integer prevInterval = notify_interval;
Boolean shouldExtendTimeInterval = Stream.of(coordinatesHistory)
.map(MapUtils::checkIfCoordinateIsValid).takeWhile(s -> !s).toList().size() == coordinatesHistory.size();
Boolean shouldAbbreviateTimeInterval = Stream.of(coordinatesHistory).
map(MapUtils::checkIfCoordinateIsValid).toList().get(coordinatesHistory.size() - 1);
Boolean shouldAbbreviateTimeInterval = Stream.of(coordinatesHistory).
map(MapUtils::checkIfCoordinateIsValid).filter(x -> x).toList().size() > 0;
if (shouldExtendTimeInterval) {
notify_interval = notify_interval_outside_building;
} else if (shouldAbbreviateTimeInterval) {
notify_interval = notify_interval_inside_building;
}
if (shouldAbbreviateTimeInterval) {
notify_interval = notify_interval_inside_building;
}
if (coordinatesHistory.size() > coordinatesHistoryLength && shouldExtendTimeInterval) {
notify_interval = notify_interval_outside_building;
}
Integer changedMode = Long.valueOf(prevInterval).compareTo(Long.valueOf(notify_interval));
if (changedMode != 0) {
updateListeners();
}
}
@ -198,50 +225,6 @@ public class BackgroundLocalizationService extends Service {
startForeground(2, notification);
}
private void getLocalizationFromListeners() {
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
return;
}
List<String> providers1 = mLocationManager.getProviders(true);
Location bestLocation = null;
AtomicReference<Boolean> triggerAnotherLocationListener = new AtomicReference<>(false);
mFusedLocationClient.getLastLocation().addOnSuccessListener(
location -> {
if (location != null) {
mLastLocation = location;
coordinatesHistory.add(location);
sendCoordinateToBackend(location);
}
triggerAnotherLocationListener.set(true);
});
if (triggerAnotherLocationListener.get()) {
for (String provider : providers1) {
Location location = mLocationManager.getLastKnownLocation(provider);
if (location == null) {
continue;
}
if (bestLocation == null || location.getAccuracy() < bestLocation.getAccuracy()) {
bestLocation = location;
}
}
coordinatesHistory.add(bestLocation);
}
}
private void sendCoordinateToBackend(Location location) {
new Task(location).execute();
}
@ -252,59 +235,49 @@ public class BackgroundLocalizationService extends Service {
super.onDestroy();
mHandler.removeCallbacks(mStatusChecker);
destroyLocationListeners();
}
if (mLocationManager != null) {
for (LocationListener listener : mLocationListeners) {
try {
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return;
}
mLocationManager.removeUpdates(listener);
} catch (Exception ex) {
Log.i(TAG, "fail to remove location listener, ignore", ex);
}
}
private void destroyLocationListeners() {
if (mFusedLocationClient != null) {
mFusedLocationClient.removeLocationUpdates(mLocationCallback);
mFusedLocationClient = null;
mLocationCallback = null;
mLocationRequest = null;
}
}
private void initializeLocationManager() {
Log.e(TAG, "initializeLocationManager - LOCATION_INTERVAL: " + LOCATION_INTERVAL + " LOCATION_DISTANCE: " + LOCATION_DISTANCE);
if (mLocationManager == null) {
mLocationManager = (LocationManager) getApplicationContext().getSystemService(Context.LOCATION_SERVICE);
private void updateListeners() {
if (mFusedLocationClient != null) {
mFusedLocationClient.removeLocationUpdates(mLocationCallback)
.addOnCompleteListener(task -> {
restartService();
mFusedLocationClient = null;
mLocationCallback = null;
mLocationRequest = null;
});
}
}
private class LocationListener implements android.location.LocationListener {
LocationListener(String provider) {
Log.e(TAG, "LocationListener " + provider);
mLastLocation = new Location(provider);
private void restartService() {
Intent stopIntent = new Intent(getApplicationContext(), BackgroundLocalizationService.class);
stopIntent.putExtra("request_stop", true);
stopService(stopIntent);
Intent startIntent = new Intent(getApplicationContext(), BackgroundLocalizationService.class);
startIntent.putExtra("notify_interval", notify_interval);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O) {
startForegroundService(startIntent);
} else {
startService(startIntent);
}
@Override
public void onLocationChanged(Location location) {
Log.e(TAG, "onLocationChanged: " + location);
mLastLocation.set(location);
}
@Override
public void onProviderDisabled(String provider) {
Log.e(TAG, "onProviderDisabled: " + provider);
}
@Override
public void onProviderEnabled(String provider) {
Log.e(TAG, "onProviderEnabled: " + provider);
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
Log.e(TAG, "onStatusChanged: " + provider);
}
}
@SuppressLint("StaticFieldLeak")
private class Task extends AsyncTask {
private ApproximatedLocalization approximatedLocalization;
@ -320,6 +293,7 @@ public class BackgroundLocalizationService extends Service {
latitude = location.getLatitude();
longitude = location.getLongitude();
altitude = location.getAltitude();
approximatedLocalization = new ApproximatedLocalization(MapUtils.loadJsonFromAsset(getApplicationContext(), "building.geojson"));
approximatedBuildingPart = approximatedLocalization.getNameOfBuildingPart(Point.fromLngLat(longitude, latitude));
}
@ -330,9 +304,8 @@ public class BackgroundLocalizationService extends Service {
String locationLevel = PrefUtils.getLocationLevel(getApplicationContext());
String status = (PrefUtils.isStatusEnabled(getApplicationContext())) ? PrefUtils.getUserStatus(getApplicationContext()) : "";
if (locationLevel.equals(SharingLevel.PRESENCE.toString())) {
if(!MapUtils.checkIfCoordinateIsValid(latitude,longitude)){
if (!MapUtils.checkIfCoordinateIsValid(latitude, longitude)) {
return null;
}
@ -350,6 +323,12 @@ public class BackgroundLocalizationService extends Service {
approximatedBuildingPart = PrefUtils.getManualLocationApproximation(getApplicationContext());
}
Location fakeLoc = new Location("");
fakeLoc.setLatitude(latitude);
fakeLoc.setLongitude(longitude);
coordinatesHistory.add(fakeLoc);
try {
Coordinate coordinate = new Coordinate(
latitude,
@ -367,7 +346,6 @@ public class BackgroundLocalizationService extends Service {
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribeWith(new DisposableCompletableObserver() {
@Override
public void onComplete() {
Log.e(TAG, "CoordinateSuccess");
@ -375,9 +353,7 @@ public class BackgroundLocalizationService extends Service {
@Override
public void onError(Throwable e) {
Log.e(TAG,"onErr" + valueOf(e));
Log.e(TAG, "onErr" + valueOf(e));
}
}));
} catch (IllegalArgumentException e) {

View File

@ -0,0 +1,24 @@
package com.uam.wmi.findmytutor.service;
import com.uam.wmi.findmytutor.model.PredefinedCoordViewModel;
import java.util.List;
import io.reactivex.Single;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.HTTP;
import retrofit2.http.POST;
import retrofit2.http.Path;
public interface PredefinedCoordinatesService {
@GET("api/users/predefined/coordinate/{tutorId}")
Single<List<PredefinedCoordViewModel>> getUserPredefinedCoords(@Path("tutorId") String tutorId);
@POST("api/users/predefined/coordinate/{tutorId}")
Single <PredefinedCoordViewModel> postUserPredefinedCoord(@Path("tutorId") String tutorId, @Body PredefinedCoordViewModel coord);
@HTTP(method = "DELETE", path = "api/users/predefined/coordinate/{tutorId}", hasBody = true)
Single<List<PredefinedCoordViewModel>> deleteUserPredefinedCoord(@Path("tutorId") String tutorId, @Body String uuid);
}

View File

@ -5,25 +5,27 @@ import io.reactivex.Single;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.HTTP;
import retrofit2.http.POST;
import retrofit2.http.Path;
public interface PredefinedStatusesService {
public interface PredefinedStatusesService {
@GET("api/users/predefined/status/{tutorId}")
Single<List<String>> getUserPredefinedStatuses(@Path("tutorId") String tutorId);
@POST("api/users/predefined/status/{tutorId}")
Single<List<String>> postUserPredefinedStatus(@Path("tutorId") String tutorId, @Body String status);
@DELETE("api/users/predefined/status/{tutorId}")
// @DELETE("api/users/predefined/status/{tutorId}")
@HTTP(method = "DELETE", path = "api/users/predefined/status/{tutorId}", hasBody = true)
Single<List<String>> deleteUserPredefinedStatus(@Path("tutorId") String tutorId, @Body String status);
@GET("api/users/predefined/coordinate/{tutorId}")
/* @GET("api/users/predefined/coordinate/{tutorId}")
Single<List<PredefinedCoordViewModel>> getUserPredefinedCoords(@Path("tutorId") String tutorId);
@POST("api/users/predefined/coordinate/{tutorId}")
Single <PredefinedCoordViewModel> postUserPredefinedCoord(@Path("tutorId") String tutorId, @Body PredefinedCoordViewModel coord);
@DELETE("api/users/predefined/coordinate/{tutorId}")
Single<List<PredefinedCoordViewModel>> deleteUserPredefinedCoord(@Path("tutorId") String tutorId, @Body PredefinedCoordViewModel coord);
Single<List<PredefinedCoordViewModel>> deleteUserPredefinedCoord(@Path("tutorId") String tutorId, @Body PredefinedCoordViewModel coord);*/
}

View File

@ -10,14 +10,17 @@ import java.util.List;
import io.reactivex.Completable;
import io.reactivex.Observable;
import io.reactivex.ObservableEmitter;
import io.reactivex.Single;
import retrofit2.Response;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.HTTP;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Path;
import retrofit2.http.Query;
public interface UserService {
@ -30,6 +33,18 @@ public interface UserService {
@GET("api/users/tutors")
Single <List<User>> getAllTutors();
@GET("api/users/tutors/online")
Single <List<User>> getAllOnlineTutors();
@GET("api/users/tutors/active")
Single <List<User>> getAllActiveTutors();
@GET("api/users/tutors/offline")
Single <List<User>> getAllOfflineTutors();
@GET("api/users/tutors/search")
Single <List<User>> searchUser(@Query(value = "searchString", encoded = true) String searchString);
@POST("api/users")
Completable createUser(@Body User user);
@ -61,26 +76,28 @@ public interface UserService {
Completable setUserInActive(@Path("userID") String userID);
@GET("api/users/blacklist/{tutorID}")
Single<List<User>> getTutorBlacklistedByID(@Path("tutorID") String tutorID);
Single <List<String>> getTutorBlacklistedByID(@Path("tutorID") String tutorID);
@PUT("api/users/blacklist/{tutorID}")
Completable setTutorBlacklist(@Path("tutorID") String tutorID, @Body IsUsingListBool isUsing);
@POST("api/users/blacklist/{tutorID}")
Completable addStudentToBlacklist(@Path("tutorID") String tutorID, @Body StudentIdModel student);
Observable <User> addStudentToBlacklist(@Path("tutorID") String tutorID, @Body StudentIdModel student);
@DELETE("api/users/blacklist/{tutorID}")
// @DELETE("api/users/blacklist/{tutorID}")
@HTTP(method = "DELETE", path = "api/users/blacklist/{tutorID}", hasBody = true)
Completable removeStudentFromBlacklist(@Path("tutorID") String tutorID, @Body StudentIdModel student);
@GET("api/users/whitelist/{tutorID}")
Single<List<User>> getTutorwhitelistedByID(@Path("tutorID") String tutorID);
Single<List<String>> getTutorWhitelistedByID(@Path("tutorID") String tutorID);
@PUT("api/users/whitelist/{tutorID}")
Completable setTutorWhitelist(@Path("tutorID") String tutorID, @Body IsUsingListBool isUsing);
@POST("api/users/whitelist/{tutorID}")
Completable addStudentTowhitelist(@Path("tutorID") String tutorID, @Body StudentIdModel student);
Observable <User> addStudentToWhitelist(@Path("tutorID") String tutorID, @Body StudentIdModel student);
@DELETE("api/users/whitelist/{tutorID}")
// @DELETE("api/users/whitelist/{tutorID}")
@HTTP(method = "DELETE", path = "api/users/whitelist/{tutorID}", hasBody = true)
Completable removeStudentFromWhitelist(@Path("tutorID") String tutorID, @Body StudentIdModel student);
}

View File

@ -7,8 +7,9 @@ import java.util.List;
public class Const {
public final static String BASE_URL = "https://s416084.projektstudencki.pl/master/";
public final static Integer mapRefreshInterval = 6000;
public final static Integer onlineBackgroundLocationInterval = 7000;
public final static Integer offlineBackgroundLocationInterval = 36000;
public final static Integer offlineBackgroundLocationInterval = 360000;
public final static Integer defaultMapZoom = 17;
public final static Integer searchMapZoom = 13;
public final static Double presenceLatitude = 52.466365;

View File

@ -60,6 +60,16 @@ public class PrefUtils {
return getSharedPreferences(context).getBoolean("key_status_enabled", false);
}
public static void enableStatus(Context context){
SharedPreferences.Editor editor = getSharedPreferences(context).edit();
editor.putBoolean("key_status_enabled", true);
editor.apply();
}
public static void disableStatus(Context context) {
SharedPreferences.Editor editor = getSharedPreferences(context).edit();
editor.putBoolean("key_status_enabled", false);
editor.apply();
}
public static String getUserStatus(Context context) {
return getSharedPreferences(context).getString("status_entry", "Dostępny");
@ -94,6 +104,11 @@ public class PrefUtils {
public static boolean isEnableSharingLocalization(Context context) {
return getSharedPreferences(context).getBoolean("key_sharing_enabled", false);
}
public static void disableSharing(Context context){
SharedPreferences.Editor editor = getSharedPreferences(context).edit();
editor.putBoolean("key_sharing_enabled", false);
editor.apply();
}
public static void storeEnableSharingLocalization(Context context, Boolean isChecked) {
SharedPreferences.Editor editor = getSharedPreferences(context).edit();
@ -197,4 +212,35 @@ public class PrefUtils {
return getSharedPreferences(context).getString("current_manual_location_name", null);
}
public static void putShowOnlyOnlineUsers(Context context, Boolean flag) {
SharedPreferences.Editor editor = getSharedPreferences(context).edit();
editor.putBoolean("show_only_online_users_in_list", flag);
editor.apply();
}
public static Boolean getShowOnlyOnlineUsers(Context context) {
return getSharedPreferences(context).getBoolean("show_only_online_users_in_list", true);
}
public static void useBlacklist(Context context, Boolean flag) {
SharedPreferences.Editor editor = getSharedPreferences(context).edit();
editor.putBoolean("blacklisting", flag);
editor.putBoolean("whitelisting", false);
editor.apply();
}
public static void useWhitelist(Context context, Boolean flag) {
SharedPreferences.Editor editor = getSharedPreferences(context).edit();
editor.putBoolean("whitelisting", flag);
editor.putBoolean("blacklisting", false);
editor.apply();
}
public static Boolean isBlackListing(Context context) {
return getSharedPreferences(context).getBoolean("blacklisting", false);
}
public static Boolean isWhiteListing(Context context) {
return getSharedPreferences(context).getBoolean("whitelisting", false);
}
}

View File

@ -2,6 +2,8 @@ package com.uam.wmi.findmytutor.utils;
import android.content.Context;
import android.preference.Preference;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
@ -9,31 +11,40 @@ import com.uam.wmi.findmytutor.R;
public class RightButtonPreference extends Preference {
private Button prefButton;
private String buttonText;
public RightButtonPreference(Context context, AttributeSet attrs) {
super(context, attrs);
setWidgetLayoutResource(R.layout.preference_button_widget);
for (int i=0;i<attrs.getAttributeCount();i++) {
String attr = attrs.getAttributeName(i);
String val = attrs.getAttributeValue(i);
if (attr.equalsIgnoreCase("text")) {
buttonText = context.getResources().getString(Integer.parseInt(val.substring(1)));
}
}
}
public void setText(String text){
prefButton.setText(text);
}
@Override
protected View onCreateView(ViewGroup parent) {
View view = super.onCreateView(parent);
// LayoutInflater li = (LayoutInflater)getContext().getSystemService( Context.LAYOUT_INFLATER_SERVICE );
// View temp =li.inflate( R.layout.preference_button_widget, parent, false);
return view;
return super.onCreateView(parent);
}
@Override
protected void onBindView(View view)
{
super.onBindView(view);
Button button = (Button)view.findViewById(R.id.button_choose_from_map);
if(button != null)
prefButton = view.findViewById(R.id.button_choose_from_map);
prefButton.setText(buttonText);
if(prefButton != null)
{
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
callChangeListener(null);
notifyChanged();
}
});
prefButton.setOnClickListener(view1 -> {
callChangeListener(null);
notifyChanged();
});
}
}

View File

@ -21,6 +21,7 @@ public class RxSearchObservable {
@Override
public boolean onQueryTextSubmit(String s) {
subject.onNext(s);
searchView.clearFocus();
return false;
}
@ -31,6 +32,8 @@ public class RxSearchObservable {
}
});

View File

@ -0,0 +1,22 @@
package com.uam.wmi.findmytutor.utils;
import android.content.Context;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.util.Log;
public class WrapContentLinearLayoutManager extends LinearLayoutManager {
public WrapContentLinearLayoutManager(Context context) {
super(context);
}
@Override
public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {
try {
super.onLayoutChildren(recycler, state);
} catch (IndexOutOfBoundsException e) {
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M0 0h24v24H0z" />
<path
android:fillColor="#FFFFFF"
android:pathData="M15 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm-9-2V7H4v3H1v2h3v3h2v-3h3v-2H6zm9 4c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z" />
</vector>

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M0 0h24v24H0z" />
<path
android:fillColor="#FFFF"
android:pathData="M2 12C2 6.48 6.48 2 12 2s10 4.48 10 10-4.48 10-10 10S2 17.52 2 12zm10 6c3.31 0 6-2.69 6-6s-2.69-6-6-6-6 2.69-6 6 2.69 6 6 6z" />
<path
android:pathData="M0 0h24v24H0z" />
</vector>

View File

@ -0,0 +1,83 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:id="@+id/activity_blacklist_container"
tools:context=".activity.BlackList">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="@dimen/app_bar_height"
android:fitsSystemWindows="true"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:expandedTitleGravity="top|right"
app:toolbarId="@+id/toolbar"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="left|bottom"
android:orientation="vertical"
android:padding="10dp"
android:layout_marginBottom="20dp"
app:layout_collapseMode="parallax">
<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="Block the users"
android:textSize="15sp"/>
<Switch
android:id="@+id/switch_blacklist_toggle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:thumbTextPadding="45dp"
android:text="BLACKLIST TEXT SWITCH" />
</LinearLayout>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/AppTheme.PopupOverlay"
/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_black_list" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/add_to_black_list_fab"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/fab_margin"
android:layout_marginTop="-322dp"
app:layout_anchor="@id/app_bar"
app:layout_anchorGravity="bottom|end"
app:srcCompat="@drawable/ic_add_person"
app:useCompatPadding="true"
tools:srcCompat="@tools:sample/backgrounds/scenic" />
<!-- A RecyclerView with some commonly used attributes -->
</android.support.design.widget.CoordinatorLayout>

View File

@ -0,0 +1,83 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:id="@+id/activity_whitelist_container"
tools:context=".activity.WhiteList">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="@dimen/app_bar_height"
android:fitsSystemWindows="true"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:expandedTitleGravity="top|right"
app:toolbarId="@+id/toolbar"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="left|bottom"
android:orientation="vertical"
android:padding="10dp"
android:layout_marginBottom="20dp"
app:layout_collapseMode="parallax">
<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="Be visible for these users"
android:textSize="15sp"/>
<Switch
android:id="@+id/switch_whitelist_toggle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:thumbTextPadding="45dp"
android:text="WHITELIST TEXT SWITCH" />
</LinearLayout>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/AppTheme.PopupOverlay"
/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_white_list" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/add_to_white_list_fab"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/fab_margin"
android:layout_marginTop="-322dp"
app:layout_anchor="@id/app_bar"
app:layout_anchorGravity="bottom|end"
app:srcCompat="@drawable/ic_add_person"
app:useCompatPadding="true"
tools:srcCompat="@tools:sample/backgrounds/scenic" />
<!-- A RecyclerView with some commonly used attributes -->
</android.support.design.widget.CoordinatorLayout>

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fontFamily="@font/lato_regular"
android:orientation="vertical"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingBottom="@dimen/activity_vertical_margin">
<TextView
android:id="@+id/black_list_modal_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="@+id/black_list_modal_input"
android:layout_marginBottom="@dimen/dimen_10"
android:fontFamily="sans-serif-medium"
android:lineSpacingExtra="8sp"
android:text="@string/black_list_title"
android:textColor="@color/colorAccent"
android:textSize="@dimen/lbl_new_note_title"
android:textStyle="normal" />
<EditText
android:id="@+id/black_list_modal_input"
android:layout_width="315dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="50dp"
android:ems="10"
android:hint="@string/index_user"
android:maxLength="30"
android:maxLines="1"
android:requiresFadingEdge="vertical"
android:scrollbars="vertical"
android:textColor="@color/note_list_text" />
</RelativeLayout>

View File

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="90dp"
android:clickable="true"
android:focusable="true"
android:paddingLeft="10dp"
android:paddingTop="@dimen/dimen_10"
android:paddingRight="10dp"
android:fontFamily="@font/lato_regular"
android:paddingBottom="@dimen/dimen_10">
<TextView
android:id="@+id/firstName"
android:layout_width="271dp"
android:layout_height="22dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="12dp"
android:layout_marginTop="10dp"
android:textColor="@color/note_list_text"
android:textSize="15sp" />
<TextView
android:id="@+id/lastName"
android:layout_width="270dp"
android:layout_height="22dp"
android:layout_below="@+id/firstName"
android:layout_alignEnd="@+id/firstName"
android:layout_marginTop="10dp"
android:layout_marginEnd="0dp"
android:textColor="@color/note_list_text"
android:textSize="15sp" />
<ImageButton
android:id="@+id/removeUserImageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/firstName"
android:layout_toEndOf="@+id/firstName"
android:background="@null"
android:layout_alignParentEnd="true"
app:srcCompat="@drawable/abc_ic_clear_material" />
</RelativeLayout>

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".activity.UsersListFragment"
android:fontFamily="@font/lato_regular"
tools:showIn="@layout/users_list_main">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view_blacklist"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TextView
android:id="@+id/black_list_empty_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/margin_top_no_notes"
android:fontFamily="sans-serif-light"
android:text="@string/loading"
android:textColor="@color/msg_no_notes"
android:textSize="@dimen/msg_no_notes" />
</RelativeLayout>

View File

@ -7,8 +7,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".activity.UsersListFragment"
android:fontFamily="@font/lato_regular"
tools:showIn="@layout/users_list_main">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view_whitelist"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TextView
android:id="@+id/white_list_empty_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/margin_top_no_notes"
android:fontFamily="sans-serif-light"
android:text="@string/loading"
android:textColor="@color/msg_no_notes"
android:textSize="@dimen/msg_no_notes" />
</RelativeLayout>

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="Homw Tab"
android:textAppearance="?android:attr/textAppearanceLarge"/>
</RelativeLayout>

View File

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:background="@drawable/layout_bg"
android:orientation="vertical"
android:padding="10dp"
android:textColor="@color/half_black">
<TextView
android:id="@+id/textViewP1_info_icon_blacklist_p1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:text="@string/info_icon_blacklist_p1"
android:textColor="@color/half_black" />
<TextView
android:id="@+id/textViewP2_info_icon_blacklist_p2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginTop="20dp"
android:layout_weight="1"
android:text="@string/info_icon_blacklist_p2"
android:textColor="@color/half_black" />
<TextView
android:id="@+id/textViewP3_info_icon_blacklist_p3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginTop="20dp"
android:layout_weight="1"
android:text="@string/info_icon_blacklist_p3"
android:textColor="@color/half_black" />
</LinearLayout>

View File

@ -72,4 +72,6 @@
android:text="@string/info_icon_userlist_summary"
android:textColor="@color/half_black"/>
</LinearLayout>

View File

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:background="@drawable/layout_bg"
android:orientation="vertical"
android:padding="10dp"
android:textColor="@color/half_black">
<TextView
android:id="@+id/textViewP1_info_icon_whitelist_p1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:text="@string/info_icon_whitelist_p1"
android:textColor="@color/half_black" />
<TextView
android:id="@+id/textViewP2_info_icon_whitelist_p2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginTop="20dp"
android:layout_weight="1"
android:text="@string/info_icon_whitelist_p2"
android:textColor="@color/half_black" />
<TextView
android:id="@+id/textViewP3_info_icon_whitelist_p3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginTop="20dp"
android:layout_weight="1"
android:text="@string/info_icon_whitelist_p3"
android:textColor="@color/half_black" />
</LinearLayout>

View File

@ -24,14 +24,14 @@
android:textStyle="normal" />
<EditText
android:id="@+id/feedback_input"
android:id="@+id/manual_input"
android:layout_width="315dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="50dp"
android:ems="10"
android:hint="@string/modal_feedback_hint"
android:hint="@string/modal_manual_hint"
android:maxLength="30"
android:maxLines="1"
android:requiresFadingEdge="vertical"

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="90dp"
android:clickable="true"
android:focusable="true"
@ -13,7 +13,7 @@
<TextView
android:id="@+id/firstName"
android:layout_width="271dp"
android:layout_width="270dp"
android:layout_height="22dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
@ -26,23 +26,25 @@
android:id="@+id/lastName"
android:layout_width="270dp"
android:layout_height="22dp"
android:layout_marginStart="12dp"
android:layout_below="@+id/firstName"
android:layout_alignEnd="@+id/firstName"
android:layout_marginTop="10dp"
android:layout_marginEnd="0dp"
android:layout_alignParentStart="true"
android:textColor="@color/note_list_text"
android:textSize="15sp" />
<TextView
android:id="@+id/isOnline"
android:layout_width="48dp"
android:layout_width="50dp"
android:layout_height="30dp"
android:layout_below="@+id/firstName"
android:layout_marginStart="7dp"
android:layout_marginTop="-10dp"
android:layout_toEndOf="@+id/firstName"
android:textColor="@color/note_list_text"
android:layout_alignParentEnd="true"
android:textSize="@dimen/note_list_text" />

View File

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<android.support.v4.app.FragmentTabHost
android:id="@+id/tabHost"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="30dp"/>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/tab1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
</LinearLayout>
<LinearLayout
android:id="@+id/tab2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
</LinearLayout>
</FrameLayout>
</LinearLayout>
<FrameLayout
android:id="@+id/realtabcontent"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_below="@+id/tabLinear"/>
</android.support.v4.app.FragmentTabHost>
</RelativeLayout>

View File

@ -27,17 +27,19 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/userName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="15dp"
android:gravity="center_horizontal"
android:textColor="@color/white"
android:textSize="@dimen/lbl_new_note_title"
android:textStyle="normal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<TextView
android:id="@+id/userName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="15dp"
android:gravity="center_horizontal"
android:textColor="@color/white"
android:textSize="@dimen/lbl_new_note_title"
android:textStyle="normal"
android:drawablePadding="10dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"/>
</android.support.constraint.ConstraintLayout>
</RelativeLayout>
@ -158,25 +160,25 @@
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal"
android:paddingLeft="20dp">
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal"
android:paddingLeft="20dp">
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:src="@drawable/user_modal_note"/>
<TextView
android:id="@+id/userNote"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textColor="@color/mapboxWhite"
android:paddingLeft="10dp"
/>
</LinearLayout>
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:src="@drawable/user_modal_note"/>
<TextView
android:id="@+id/userNote"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textColor="@color/mapboxWhite"
android:paddingLeft="10dp"
/>
</LinearLayout>
</LinearLayout>

View File

@ -10,6 +10,7 @@
<include layout="@layout/users_list_main" />
</android.support.design.widget.CoordinatorLayout>

View File

@ -12,6 +12,7 @@
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:scrollbars="vertical"
android:layout_height="match_parent" />
<TextView

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:mapbox="http://schemas.android.com/apk/res-auto"
android:id="@+id/coordinator_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fontFamily="@font/lato_regular"
tools:context=".activity.UsersListFragment">
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</android.support.design.widget.CoordinatorLayout>

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fontFamily="@font/lato_regular"
android:orientation="vertical"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingBottom="@dimen/activity_vertical_margin">
<TextView
android:id="@+id/white_list_modal_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="@+id/white_list_modal_input"
android:layout_marginBottom="@dimen/dimen_10"
android:fontFamily="sans-serif-medium"
android:lineSpacingExtra="8sp"
android:text="@string/white_list_title"
android:textColor="@color/colorAccent"
android:textSize="@dimen/lbl_new_note_title"
android:textStyle="normal" />
<EditText
android:id="@+id/white_list_modal_input"
android:layout_width="315dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="50dp"
android:ems="10"
android:hint="@string/index_user"
android:maxLength="30"
android:maxLines="1"
android:requiresFadingEdge="vertical"
android:scrollbars="vertical"
android:textColor="@color/note_list_text" />
</RelativeLayout>

View File

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="90dp"
android:clickable="true"
android:focusable="true"
android:paddingLeft="10dp"
android:paddingTop="@dimen/dimen_10"
android:paddingRight="10dp"
android:fontFamily="@font/lato_regular"
android:paddingBottom="@dimen/dimen_10">
<TextView
android:id="@+id/firstName"
android:layout_width="271dp"
android:layout_height="22dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="12dp"
android:layout_marginTop="10dp"
android:textColor="@color/note_list_text"
android:textSize="15sp" />
<TextView
android:id="@+id/lastName"
android:layout_width="270dp"
android:layout_height="22dp"
android:layout_below="@+id/firstName"
android:layout_alignEnd="@+id/firstName"
android:layout_marginTop="10dp"
android:layout_marginEnd="0dp"
android:textColor="@color/note_list_text"
android:textSize="15sp" />
<ImageButton
android:id="@+id/removeUserImageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/firstName"
android:layout_toEndOf="@+id/firstName"
android:background="@null"
android:layout_alignParentEnd="true"
app:srcCompat="@drawable/abc_ic_clear_material" />
</RelativeLayout>

View File

@ -1,14 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group android:id="@+id/drawer_group_tutor">
<!-- <item
<item
android:id="@+id/nav_item_one"
android:icon="@drawable/ic_people_white"
android:title="@string/navigation_item_whitelist" />
<item
android:id="@+id/nav_item_two"
android:icon="@drawable/ic_people_black"
android:title="@string/navigation_item_blacklist" />-->
android:title="@string/navigation_item_blacklist" />
<item
android:id="@+id/nav_item_three"
android:icon="@drawable/outline_person_white_24dp"

View File

@ -0,0 +1,11 @@
<menu 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"
tools:context="com.uam.wmi.findmytutor.activity.BlackList">
<item
android:id="@+id/action_blacklist_info_popup"
android:orderInCategory="100"
android:title="Popup info icon"
android:icon="@drawable/outline_info_24"
app:showAsAction="ifRoom" />
</menu>

View File

@ -6,6 +6,8 @@
android:id="@+id/action_search"
android:icon="@drawable/ic_menu_search"
app:showAsAction="always"
android:focusable="true"
android:focusableInTouchMode="true"
app:actionViewClass="android.support.v7.widget.SearchView"
android:title="@string/search"/>
<item

View File

@ -0,0 +1,11 @@
<menu 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"
tools:context="com.uam.wmi.findmytutor.activity.BlackList">
<item
android:id="@+id/action_whitelist_info_popup"
android:orderInCategory="100"
android:title="Popup info icon"
android:icon="@drawable/outline_info_24"
app:showAsAction="ifRoom" />
</menu>

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/showOnlineUsersOnly"
android:checkable="true"
android:title="@string/only_online_users"
app:actionViewClass="android.widget.CheckBox"
app:showAsAction="never" />
</menu>

View File

@ -132,7 +132,7 @@
<string name="fab_title_bound_area">Bounds OFF</string>
<string name="email_subject_feedback">Find My Tutor - feedback</string>
<string name="email_subject_bug">Find My Tutor - zgłoszenie błędu</string>
<string name="modal_feedback_hint">Proszę opisz swoje spostrzeżnia.</string>
<string name="modal_feedback_hint">Opisz proszę swoje spostrzeżenia.</string>
<string name="modal_feedback_question">Wyślij anonimowo</string>
<string name="location_level_manual">Manualna</string>
<string name="preference_manual_location_button">Wybierz z mapy</string>
@ -205,12 +205,16 @@
<string name="info_icon_sharing_tab_p6">Dodatkowo, do Twojej lokalizacji możesz dodać status opisowy (będzie on widoczny dla użytkowników po kliknięciu w marker).</string>
<string name="info_icon_sharing_tab_p7">Zarówno manualne lokalizacje jak i statusy możesz dodać do listy, z której możesz potem je wybrać w wygodny sposób.</string>
<!--(PL) Userlist Tab info helper-->
<string name="info_icon_userlist_tab_p1">W tym panelu znajduje się listę profesorów.</string>
<string name="info_icon_userlist_tab_p1">W tym panelu znajduje się lista profesorów.</string>
<string name="info_icon_userlist_tab_p2">Ich status symbolizowany jest przez kolorowe kropki:</string>
<string name="info_icon_userlist_tab_level_status_online">- użytkownik jest obecnie online</string>
<string name="info_icon_userlist_tab_level_status_offline">- użytkownik jest obecnie offline</string>
<string name="info_icon_userlist_tab_level_status_inactive">- użytkownik jest nieaktywny</string>
<string name="info_icon_userlist_tab_level_status_inactive_tip">(nie udostępnił żadnych danych o lokalizacji od conajmniej tygodnia)</string>
<string name="add">Dodaj</string>
<string name="index_user">Index użytkownika</string>
<string name="black_list_title">Dodaj użytkownika do Blacklsi</string>
<string name="info_icon_userlist_summary">Po kliknięciu w imię i nazwisko, wyświetli się karta zawierająca dokładne informacje o profesorze.</string>
@ -239,9 +243,39 @@
<string name="negative_dialog_button">Nie</string>
<string name="enable_sharing_question">Aby skorzystać z tej funkcji musisz pozwolić na udostępnianie lokalizacji. Zgadzasz sie?</string>
<string name="sharing_modal_title">Udostępnianie</string>
<string name="preference_manual_location_button_remove">Zarządzaj zapisanymi</string>
<string name="preference_manual_status_button_remove">Zarządzaj zapisanymi</string>
<string name="blacklist">Czarna lista</string>
<string name="can_not_be_empty">Pole nie może być puste</string>
<string name="user_added">Użytkownik dodany</string>
<string name="list_is_empty">Lista jest pusta</string>
<string name="on">WŁĄCZONA</string>
<string name="off">WYŁĄCZONA</string>
<string name="title_activity_black_list">Czarna lista</string>
<string name="scrap_tutor_tab">Pobierz dane z WMI</string>
<string name="scrap_tutor_msg">Dane zostały zaktualizwane!</string>
<!--(ENG) Checkbox online users list -->
<string name="no_online_users">Brak aktywnych użytkowników.</string>
<string name="no_offline_users">Brak użytkowników offline.</string>
<string name="activity_title_blacklist">Czarna lista</string>
<string name="activity_title_whitelist">Biała lista</string>
<string name="title_activity_white_list">Biała lista</string>
<string name="white_list_title">Dodaj użytkownika do białej listy</string>
<string name="no_such_a_user">Nie ma takiego użytkownika</string>
<string name="only_online_users">Tylko aktywni użytkownicy</string>
<string name="network_err">Błąd sieci!</string>
<string name="search_null">Brak wyników!</string>
<string name="modal_manual_hint">Nadaj nazwę tej lokalizacji.</string>
<string name="online">Dostępny</string>
<string name="offline">Niedostępny</string>
<string name="inactive">Nieaktywny</string>
<string name="show_on_map">POKAŻ NA MAPIE</string>
<!--(ENG) Blacked/Whited users -->
<string name="add_user_to_list">Użytkownik został dodany!</string>
<string name="user_removed">Użytkownik usunięty!</string>
</resources>

View File

@ -55,23 +55,15 @@
</string-array>
<string-array name="status_entries">
<item>@string/description_available</item>
<item>@string/description_busy</item>
<item>@string/description_consultation</item>
</string-array>
<string-array name="status_values">
<item>0</item>
<item>1</item>
<item>2</item>
</string-array>
<string-array name="manual_location_entries">
<item>@string/assembly_c</item>
<item>@string/assembly_a</item>
<item>@string/passage_d</item>
</string-array>
<string-array name="manual_location_values">
<item>0</item>
<item>1</item>
<item>2</item>
</string-array>
<string-array name="language_entries">
<item>@string/lang_eng</item>
@ -81,4 +73,19 @@
<item>0</item>
<item>1</item>
</string-array>
<string-array name="yourArray">
<item>Item 1</item>
<item>Item 2</item>
<item>Item 3</item>
<item>Item 4</item>
</string-array>
<string-array name="yourValues">
<item>0</item>
<item>1</item>
<item>2</item>
<item>3</item>
</string-array>
</resources>

View File

@ -19,4 +19,6 @@
<dimen name="note_list_text">13sp</dimen>
<dimen name="default_margin">12dp</dimen>
<dimen name="text_large">10dp</dimen>
<dimen name="app_bar_height">180dp</dimen>
<dimen name="text_margin">16dp</dimen>
</resources>

View File

@ -32,7 +32,8 @@
<!-- Tutors list -->
<string name="action_settings">Settings</string>
<string name="activity_title_home">Notes</string>
<string name="activity_title_blacklist">Blacklist</string>
<string name="activity_title_whitelist">Whitelist</string>
<string name="prompt_password">Password</string>
<string name="action_sign_in">Sign in or register</string>
<string name="action_sign_out">Sign out</string>
@ -53,12 +54,10 @@
<!-- Strings related to SharingActivity -->
<string name="title_activity_sharing">Sharing</string>
<!-- Strings related to settings -->
<string name="title_sharing">Sharing</string>
<string name="settings_category_location">Location sharing</string>
<string name="settings_category_status">Status settings</string>
@ -69,6 +68,9 @@
<string name="location_level_precise">Exact</string>
<string name="location_level_manual">Manual</string>
<string name="preference_manual_location_button">Choose from map</string>
<string name="preference_manual_location_button_remove">Manage saved</string>
<string name="preference_manual_status_button_remove">Manage saved</string>
<string name="settings_location_level">Location level</string>
<string name="key_location_level">key_location_level</string>
@ -86,14 +88,10 @@
<string name="title_manual_status">Add custom status</string>
<string name="settings_description">Descrition</string>
<string name="settings_description">Description</string>
<string name="saveButton">Save</string>
<string name="tutorTabHint">Edit your note. It will be shown in the users list.</string>
<string name="key_description">key_description</string>
<string name="manual_location">Manual location</string>
<string name="title_list_manual_location">Choose manual location</string>
<string name="title_manual_location">Add custom location</string>
@ -254,7 +252,7 @@
<string name="pref_disable_acra" translatable="false">App issues reporting</string>
<!--(ENG) Map Activity info helper-->
<string name="map_info_text_p1">On the map there are markers which represents tutors sharing their location right now.</string>
<string name="map_info_text_p1">On the map there are markers which represent tutors sharing their location right now.</string>
<string name="map_info_text_p2">After clicking on a marker, you can check who is sharing it and the descriptive status (if the tutor have set one).</string>
<string name="map_info_text_p3">In the app there are 3 possible types of localization, represented by various colors.</string>
<string name="map_info_text_marker_exact">exact localization (from mobile GPS)</string>
@ -288,7 +286,7 @@
<string name="info_icon_sharing_tab_p4">Each level, except from manual, will be automatically turned on when entering, and turn off when leaving the faculty. You only need to make sure that sharing is on, and the localization will be shared only when on the faculty.</string>
<string name="info_icon_sharing_tab_p5">Sharing can be turned off at any time with the switch.</string>
<string name="info_icon_sharing_tab_p6">Additionally, you can add descriptive status to your localization (visible for users after clicking on a marker).</string>
<string name="info_icon_sharing_tab_p7">Both manual localizations and statuses can be added to a list, and then used them in a convenient way. </string>
<string name="info_icon_sharing_tab_p7">Both manual localizations and statuses can be added to a list, and then used in a convenient way. </string>
<!--(ENG) Userlist tab info helper-->
<string name="info_icon_userlist_tab_p1">This panel contains the list of tutors.</string>
@ -297,10 +295,18 @@
<string name="info_icon_userlist_tab_level_status_offline">- user is currently offline</string>
<string name="info_icon_userlist_tab_level_status_inactive">- user is inactive </string>
<string name="info_icon_userlist_tab_level_status_inactive_tip">(didnt share any localization data since 7 days)</string>
<string name="info_icon_userlist_summary">After clicking on a name, the tutor tab will pop up, containing details about selected tutor.</string>
<string name="title_activity_black_list">BlackList</string>
<string name="title_activity_white_list">Whitelist</string>
<string name="white_list_title">Add user to Whitelist</string>
<string name="info_icon_userlist_summary">After clicking on a name, the tutor tab will pop up, containing details about selected tutor.\n\nYou can search for any tutor on the map by entering his name and surname in the search field.\n\nBy default, only active users are shown. You can change that in menu (three dots icon).\n\nYou can also search for a tutor directly, by entering name and surname of person that you look for.</string>
<!--(ENG) Blacklist -->
<string name="index_user">User index</string>
<string name="black_list_title">Add user to blacklist</string>
<string name="add">Add</string>
<string name="possitive_dialog_button">Yes</string>
<string name="pref_title_acra" translatable="false">App issues reporting</string>
<!--(ENG) Profile Activity strings-->
@ -319,7 +325,31 @@
<string name="enable_sharing_question">In order to use this function, you have to enable localization sharing. May I do it for you?</string>
<string name="sharing_modal_title">Sharing</string>
<string name="lack_of_status">The user hasn\'t defined a status.</string>
<string name="can_not_be_empty">Field can not be empty</string>
<string name="user_added">User added</string>
<string name="list_is_empty">The list is empty</string>
<string name="activity_title_home">Map</string>
<string name="on">ON</string>
<string name="off">OFF</string>
<string name="scrap_tutor_tab">Scrap!</string>
<string name="scrap_tutor_msg">Thank you for scraping your tab!</string>
<string name="scrap_tutor_msg">Data updated!</string>
<!--(ENG) Checkbox online users list -->
<string name="no_online_users">Currently, there are no\nactive users.</string>
<string name="no_offline_users">Currently, there are no\noffline users.</string>
<string name="only_online_users">Only online users</string>
<string name="no_such_a_user">No such a user</string>
<string name="network_err">Network Error !</string>
<string name="search_null">Search response is empty!</string>
<string name="modal_manual_hint">Insert a name for this localization.</string>
<string name="online">Online</string>
<string name="offline">Offline</string>
<string name="inactive">Inactive</string>
<string name="show_on_map">SHOW ON MAP</string>
<!--(ENG) Blacked/Whited users -->
<string name="add_user_to_list">User has been added!</string>
<string name="user_removed">User removed!</string>
</resources>

View File

@ -22,4 +22,5 @@
<item name="android:background">@drawable/fab_label_background</item>
<item name="android:textColor">@color/mapboxWhite</item>
</style>
</resources>

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
tools:ignore="MissingDefaultResource"
android:layout_width="match_parent"
android:id="@+id/pref_screen"
android:fontFamily="@font/lato_regular"
android:layout_height="match_parent">
@ -16,7 +16,7 @@
android:persistent="true"
android:title="@string/title_sharing"/>
<ListPreference
android:defaultValue="1"
android:defaultValue="2"
android:dialogTitle="@string/settings_location_level"
android:entries="@array/location_level_entries"
android:entryValues="@array/location_level_values"
@ -27,9 +27,16 @@
android:defaultValue="0"
android:key="key_manual_location_value"
android:summary="%s"
android:entries="@array/manual_location_entries"
android:entryValues="@array/manual_location_values"
android:title="@string/title_list_manual_location" />
<com.uam.wmi.findmytutor.utils.RightButtonPreference
android:key="manual_location_button"
android:text="@string/preference_manual_location_button"
/>
<com.uam.wmi.findmytutor.utils.RightButtonPreference
android:key="remove_manual_location"
android:text="@string/preference_manual_location_button_remove"
/>
</PreferenceCategory>
@ -41,9 +48,11 @@
android:persistent="true"
android:title="@string/status_switch_title"/>
<ListPreference
android:defaultValue="2"
android:defaultValue="0"
android:key="@string/key_status_value"
android:summary="%s"
android:entries="@array/status_entries"
android:entryValues="@array/status_values"
android:title="@string/status_list_title" />
<EditTextPreference
android:key="key_manual_status"
@ -51,8 +60,10 @@
android:singleLine="true"
android:title="@string/title_manual_status"
/>
<com.uam.wmi.findmytutor.utils.RightButtonPreference
android:key="remove_manual_status"
android:text="@string/preference_manual_status_button_remove"
/>
</PreferenceCategory>
</PreferenceScreen>