Compare commits
No commits in common. "master" and "fix-blacklists" have entirely different histories.
master
...
fix-blackl
@ -10,11 +10,10 @@ android {
|
||||
applicationId "com.uam.wmi.findmytutor"
|
||||
minSdkVersion 22
|
||||
targetSdkVersion 27
|
||||
versionCode 66
|
||||
versionName "1.0.0"
|
||||
versionCode 22
|
||||
versionName "0.9.5-beta"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
resConfigs "en", "pl"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
@ -38,8 +37,10 @@ dependencies {
|
||||
implementation "ch.acra:acra-limiter:$acraVersion"
|
||||
|
||||
|
||||
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
implementation 'com.android.support:preference-v7:27.1.1'
|
||||
implementation 'com.android.support:appcompat-v7:27.1.1'
|
||||
implementation 'com.android.support:cardview-v7:27.1.1'
|
||||
implementation 'com.android.support:design:27.1.1'
|
||||
implementation 'com.android.support:support-v4:27.1.1'
|
||||
@ -71,10 +72,4 @@ dependencies {
|
||||
// FloatingBarMenu
|
||||
implementation 'com.getbase:floatingactionbutton:1.10.1'
|
||||
implementation 'org.apache.commons:commons-collections4:4.0'
|
||||
implementation 'com.android.support:design:27.1.1'
|
||||
|
||||
// spinner loaders library
|
||||
implementation 'com.github.ybq:Android-SpinKit:1.2.0'
|
||||
// rx binding
|
||||
implementation 'com.jakewharton.rxbinding:rxbinding:0.3.0'
|
||||
}
|
||||
|
@ -4,10 +4,10 @@
|
||||
package="com.uam.wmi.findmytutor">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_UPDATES" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
|
||||
@ -24,7 +24,6 @@
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme"
|
||||
android:configChanges="locale"
|
||||
tools:ignore="AllowBackup,GoogleAppIndexingWarning">
|
||||
<activity
|
||||
android:name=".activity.StartupActivity"
|
||||
@ -39,11 +38,11 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
android:name=".activity.MapActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
||||
android:launchMode="singleTop"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.LoginActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
||||
@ -61,11 +60,9 @@
|
||||
android:enabled="true"
|
||||
android:exported="false"
|
||||
android:launchMode="singleTop" />
|
||||
|
||||
<activity
|
||||
android:name=".activity.TutorTab"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
||||
android:windowSoftInputMode="stateHidden|adjustPan"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme" />
|
||||
<activity
|
||||
@ -78,7 +75,6 @@
|
||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme" />
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
@ -6,9 +6,8 @@ import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
|
||||
import com.uam.wmi.findmytutor.utils.Const;
|
||||
import com.uam.wmi.findmytutor.utils.MapUtils;
|
||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||
|
||||
import static org.acra.ReportField.*;
|
||||
import org.acra.ACRA;
|
||||
import org.acra.annotation.AcraLimiter;
|
||||
import org.acra.annotation.AcraNotification;
|
||||
@ -17,32 +16,18 @@ import org.acra.config.HttpSenderConfigurationBuilder;
|
||||
import org.acra.config.ToastConfigurationBuilder;
|
||||
import org.acra.data.StringFormat;
|
||||
import org.acra.sender.HttpSender;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.acra.ReportField.ANDROID_VERSION;
|
||||
import static org.acra.ReportField.BUILD_CONFIG;
|
||||
import static org.acra.ReportField.CUSTOM_DATA;
|
||||
import static org.acra.ReportField.LOGCAT;
|
||||
import static org.acra.ReportField.PHONE_MODEL;
|
||||
import static org.acra.ReportField.REPORT_ID;
|
||||
import static org.acra.ReportField.SHARED_PREFERENCES;
|
||||
import static org.acra.ReportField.STACK_TRACE;
|
||||
import static org.acra.ReportField.USER_APP_START_DATE;
|
||||
import static org.acra.ReportField.USER_CRASH_DATE;
|
||||
|
||||
|
||||
@AcraNotification(resText = R.string.notification_text,
|
||||
resTitle = R.string.notification_title,
|
||||
resChannelName = R.string.notification_channel)
|
||||
@AcraLimiter(failedReportLimit = 2)
|
||||
public class FindMyTutor extends Application {
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context base) {
|
||||
super.attachBaseContext(base);
|
||||
//super.attachBaseContext(LocaleHelper.onAttach(base));
|
||||
|
||||
// ACRA core
|
||||
CoreConfigurationBuilder builder = new CoreConfigurationBuilder(this)
|
||||
@ -58,17 +43,16 @@ public class FindMyTutor extends Application {
|
||||
ToastConfigurationBuilder.class
|
||||
).setResText(R.string.acra_toast_text);
|
||||
|
||||
|
||||
SharedPreferences sharedPreferences = base.getSharedPreferences("com.uam.wmi.findmytutor_preferences", Context.MODE_PRIVATE);
|
||||
Map header = new HashMap();
|
||||
String token = sharedPreferences.getString("API_KEY", "KEY_EMPTY");
|
||||
header.put("Authorization", "Bearer " + token);
|
||||
header.put("Authorization","Bearer " + token);
|
||||
|
||||
// Api POST
|
||||
builder.getPluginConfigurationBuilder(
|
||||
HttpSenderConfigurationBuilder.class
|
||||
// ).setUri("http://192.168.0.15:3000/api/acra")
|
||||
).setUri(Const.BASE_URL + "api/Feedback/autoFeedback")
|
||||
).setUri(Const.BASE_URL +"api/Feedback/autoFeedback")
|
||||
.setHttpMethod(HttpSender.Method.POST)
|
||||
.setHttpHeaders(header)
|
||||
.setEnabled(true);
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.uam.wmi.findmytutor.activity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Bundle;
|
||||
@ -14,8 +13,6 @@ import android.view.MenuInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.uam.wmi.findmytutor.utils.LocaleHelper;
|
||||
|
||||
/**
|
||||
* A {@link android.preference.PreferenceActivity} which implements and proxies the necessary calls
|
||||
* to be used with AppCompat.
|
||||
|
@ -4,7 +4,6 @@ import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Fragment;
|
||||
import android.app.FragmentTransaction;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
@ -36,9 +35,6 @@ import com.uam.wmi.findmytutor.R;
|
||||
import com.uam.wmi.findmytutor.service.BackgroundLocalizationService;
|
||||
import com.uam.wmi.findmytutor.utils.ActiveFragment;
|
||||
import com.uam.wmi.findmytutor.utils.FeedbackUtils;
|
||||
import com.uam.wmi.findmytutor.utils.LocaleHelper;
|
||||
import com.uam.wmi.findmytutor.utils.LocaleUtils;
|
||||
import com.uam.wmi.findmytutor.utils.MapUtils;
|
||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||
import com.uam.wmi.findmytutor.utils.RxSearchObservable;
|
||||
|
||||
@ -84,16 +80,11 @@ public abstract class BaseActivity
|
||||
private SharingFragment sharingFragment;
|
||||
|
||||
private Fragment userListFragment;
|
||||
public ActiveFragment activeFragment = ActiveFragment.NONE;
|
||||
private ActiveFragment activeFragment = ActiveFragment.NONE;
|
||||
private Fragment activeBottomMenu = null;
|
||||
public SearchView searchView;
|
||||
private SearchView searchView;
|
||||
public MenuItem infoMenuItem;
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context base) {
|
||||
super.attachBaseContext(LocaleHelper.onAttach(base));
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -127,9 +118,17 @@ public abstract class BaseActivity
|
||||
if(PrefUtils.isBackgroundLocationServiceRunning(getApplicationContext())) {
|
||||
stopBackgroundLocalizationTask();
|
||||
}
|
||||
logout();
|
||||
|
||||
storeBackgroundLocationStatus(getApplication(), false);
|
||||
PrefUtils.storeIsLoggedIn(getApplicationContext(), false);
|
||||
|
||||
Intent i = getBaseContext().getPackageManager()
|
||||
.getLaunchIntentForPackage(getBaseContext().getPackageName());
|
||||
if (i != null) {
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
}
|
||||
startActivity(i);
|
||||
finish();
|
||||
} else if (itemName.equals(getResources().getString(R.string.navigation_item_feedback))) {
|
||||
feedbackUtils.showNoteDialog("FEEDBACK");
|
||||
|
||||
@ -158,21 +157,6 @@ public abstract class BaseActivity
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void logout(){
|
||||
storeBackgroundLocationStatus(getApplication(), false);
|
||||
PrefUtils.storeIsLoggedIn(getApplicationContext(), false);
|
||||
PrefUtils.setBatteryExlusionInfoStatus(getApplicationContext(), true);
|
||||
|
||||
Intent i = getBaseContext().getPackageManager()
|
||||
.getLaunchIntentForPackage(getBaseContext().getPackageName());
|
||||
if (i != null) {
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
}
|
||||
startActivity(i);
|
||||
finish();
|
||||
}
|
||||
|
||||
protected void checkPermissions() {
|
||||
final List<String> missingPermissions = new ArrayList<String>();
|
||||
|
||||
@ -215,8 +199,6 @@ public abstract class BaseActivity
|
||||
}
|
||||
|
||||
public void stopBackgroundLocalizationTask() {
|
||||
PrefUtils.storeEnableSharingLocalization(getApplicationContext(), false);
|
||||
|
||||
Intent stopIntent = new Intent(getApplicationContext(), BackgroundLocalizationService.class);
|
||||
stopIntent.putExtra("request_stop", true);
|
||||
|
||||
@ -226,12 +208,11 @@ public abstract class BaseActivity
|
||||
|
||||
public void startBackgroundLocalizationTask() {
|
||||
checkPermissions();
|
||||
PrefUtils.storeEnableSharingLocalization(getApplicationContext(), true);
|
||||
|
||||
Intent startIntent = new Intent(getApplicationContext(), BackgroundLocalizationService.class);
|
||||
startIntent.putExtra("notify_interval", onlineBackgroundLocationInterval);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O) {
|
||||
startForegroundService(startIntent);
|
||||
} else {
|
||||
startService(startIntent);
|
||||
@ -285,6 +266,7 @@ public abstract class BaseActivity
|
||||
setUpNav();
|
||||
|
||||
actionBarDrawerToggle.syncState();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -407,14 +389,11 @@ public abstract class BaseActivity
|
||||
if (itemId == R.id.nav_map) {
|
||||
removeFragment(sharingFragment);
|
||||
removeFragment(userListFragment);
|
||||
activeFragment = ActiveFragment.NONE;
|
||||
findViewById(R.id.action_search).setVisibility(View.VISIBLE);
|
||||
activeFragment = ActiveFragment.NONE;
|
||||
} 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);
|
||||
@ -427,8 +406,8 @@ public abstract class BaseActivity
|
||||
sharingFragment = SharingFragment.newInstance();
|
||||
FragmentTransaction ft = getFragmentManager().beginTransaction();
|
||||
ft.replace(R.id.activity_content, sharingFragment);
|
||||
//ft.addToBackStack(null);
|
||||
ft.commit();
|
||||
|
||||
}
|
||||
|
||||
private void loadUserListFragment() {
|
||||
@ -437,12 +416,11 @@ public abstract class BaseActivity
|
||||
userListFragment = UsersListFragment.newInstance();
|
||||
FragmentTransaction ft = getFragmentManager().beginTransaction();
|
||||
ft.replace(R.id.activity_content, userListFragment);
|
||||
//ft.addToBackStack(null);
|
||||
ft.commit();
|
||||
|
||||
}
|
||||
|
||||
public void updateNavigationBarState() {
|
||||
private void updateNavigationBarState() {
|
||||
int actionId = getNavigationMenuItemId();
|
||||
selectBottomNavigationBarItem(actionId);
|
||||
}
|
||||
@ -454,8 +432,4 @@ public abstract class BaseActivity
|
||||
|
||||
abstract int getNavigationMenuItemId();
|
||||
abstract int getContentViewId();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.uam.wmi.findmytutor.activity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.CoordinatorLayout;
|
||||
@ -32,7 +31,6 @@ import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import android.widget.ToggleButton;
|
||||
|
||||
import com.github.ybq.android.spinkit.SpinKitView;
|
||||
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
|
||||
import com.mapbox.geojson.Point;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
@ -46,31 +44,21 @@ import com.uam.wmi.findmytutor.model.UserResponseModel;
|
||||
import com.uam.wmi.findmytutor.network.ApiClient;
|
||||
import com.uam.wmi.findmytutor.service.PredefinedStatusesService;
|
||||
import com.uam.wmi.findmytutor.service.UserService;
|
||||
import com.uam.wmi.findmytutor.utils.LocaleHelper;
|
||||
import com.uam.wmi.findmytutor.utils.MyDividerItemDecoration;
|
||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||
import com.uam.wmi.findmytutor.utils.RecyclerTouchListener;
|
||||
import com.uam.wmi.findmytutor.utils.RestApiHelper;
|
||||
import com.uam.wmi.findmytutor.utils.SharingLevel;
|
||||
import com.uam.wmi.findmytutor.utils.WrapContentLinearLayoutManager;
|
||||
|
||||
import java.text.Collator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.ObservableSource;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.functions.Function;
|
||||
import io.reactivex.observers.DisposableObserver;
|
||||
import io.reactivex.observers.DisposableSingleObserver;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.ResponseBody;
|
||||
@ -90,19 +78,10 @@ public class BlackList extends AppCompatActivity {
|
||||
Switch aSwitch;
|
||||
@BindView(R.id.add_to_black_list_fab)
|
||||
FloatingActionButton addToBlackListFab;
|
||||
@BindView(R.id.loader)
|
||||
SpinKitView loader;
|
||||
|
||||
|
||||
private Integer prevSize;
|
||||
private BlackListAdapter mAdapter;
|
||||
private List<User> blacklistedUsers = new ArrayList<>();
|
||||
private Collator plCollator = Collator.getInstance(Locale.forLanguageTag("pl-PL"));
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context base) {
|
||||
super.attachBaseContext(LocaleHelper.onAttach(base));
|
||||
}
|
||||
private HashSet<String> blacklistedUsersIDs = new HashSet<>();
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -110,17 +89,16 @@ public class BlackList extends AppCompatActivity {
|
||||
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||
setContentView(R.layout.activity_black_list);
|
||||
ButterKnife.bind(this);
|
||||
|
||||
tutorId = PrefUtils.getUserId(getApplicationContext());
|
||||
userService = ApiClient.getClient(getApplicationContext())
|
||||
.create(UserService.class);
|
||||
|
||||
if (PrefUtils.isBlackListing(this)){
|
||||
aSwitch.setText(getString(R.string.action_black_list) + " " +getString(R.string.on));
|
||||
aSwitch.setText(getString(R.string.action_black_list) +" ON");
|
||||
aSwitch.setChecked(true);
|
||||
handleChangeRequest(true);
|
||||
}else{
|
||||
aSwitch.setText(getString(R.string.action_black_list) + " " +getString(R.string.off) );
|
||||
aSwitch.setText(getString(R.string.action_black_list) +" OFF");
|
||||
aSwitch.setChecked(false);
|
||||
handleChangeRequest(false);
|
||||
}
|
||||
@ -130,13 +108,12 @@ public class BlackList extends AppCompatActivity {
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
mAdapter = new BlackListAdapter(this, blacklistedUsers);
|
||||
recyclerView.setLayoutManager(new WrapContentLinearLayoutManager(getApplicationContext()));
|
||||
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getApplicationContext());
|
||||
recyclerView.setLayoutManager(mLayoutManager);
|
||||
recyclerView.setItemAnimator(new DefaultItemAnimator());
|
||||
recyclerView.addItemDecoration(new MyDividerItemDecoration(this, LinearLayoutManager.VERTICAL, 16));
|
||||
recyclerView.setAdapter(mAdapter);
|
||||
noNotesView.setVisibility(View.GONE);
|
||||
|
||||
fetchBlackListedUsers();
|
||||
/**
|
||||
* On long press on RecyclerView item, open alert dialog
|
||||
* with options to choose
|
||||
@ -154,59 +131,58 @@ public class BlackList extends AppCompatActivity {
|
||||
}));
|
||||
|
||||
addToBlackListFab.setOnClickListener(this::showFabDialog);
|
||||
|
||||
fetchBlackListedUsersIDs(PrefUtils.getUserId(getApplicationContext()));
|
||||
handleSwitch();
|
||||
}
|
||||
|
||||
private Observable<List<String>> getListOfBlacklistedUsers(String userId) {
|
||||
return userService.getTutorBlacklistedByID(userId)
|
||||
.toObservable()
|
||||
private void fetchBlackListedUsersIDs(String userId) {
|
||||
disposable.add(
|
||||
userService.getTutorBlacklistedByID(userId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeWith(new DisposableSingleObserver<List<String>>() {
|
||||
@Override
|
||||
public void onSuccess(List<String> users) {
|
||||
blacklistedUsersIDs.addAll(users);
|
||||
didFetched = true;
|
||||
fetchBlackListedUsers();
|
||||
toggleEmptyNotes();
|
||||
}
|
||||
|
||||
private Observable<User> getUserObservable(String userId) {
|
||||
return userService
|
||||
.getUserById(userId)
|
||||
.toObservable()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
showError(e);
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
private void fetchBlackListedUsers() {
|
||||
disposable.add(getListOfBlacklistedUsers(tutorId)
|
||||
.doOnSubscribe(this::handleDoOnSubscribe)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.flatMap(Observable::fromIterable)
|
||||
.flatMap(this::getUserObservable)
|
||||
.subscribe(user -> blacklistedUsers.add(user), this::handleError,this::handleComplete));
|
||||
for (String GUID : blacklistedUsersIDs){
|
||||
disposable.add(
|
||||
userService.getUserById(GUID)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeWith(new DisposableSingleObserver<User>() {
|
||||
@Override
|
||||
public void onSuccess(User user) {
|
||||
blacklistedUsers.add(user);
|
||||
toggleEmptyNotes();
|
||||
if (blacklistedUsers.size() == blacklistedUsersIDs.size()) {
|
||||
mAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
showError(e);
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleDoOnSubscribe(Disposable disposable) {
|
||||
prevSize = blacklistedUsers.size();
|
||||
blacklistedUsers.clear();
|
||||
didFetched = false;
|
||||
}
|
||||
|
||||
private void handleComplete() {
|
||||
Collections.sort(blacklistedUsers, this::sortByUserName);
|
||||
didFetched = true;
|
||||
refreshUI();
|
||||
}
|
||||
private void handleError(Throwable e){
|
||||
showError(e);
|
||||
didFetched = false;
|
||||
}
|
||||
|
||||
private void refreshUI(){
|
||||
toggleEmptyNotes();
|
||||
mAdapter.notifyItemRangeInserted(prevSize, blacklistedUsers.size() - prevSize);
|
||||
mAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
private int sortByUserName(User t1, User t2) {
|
||||
return plCollator.compare(t1.getLastName(), t2.getLastName());
|
||||
}
|
||||
|
||||
private void showFabDialog(View v){
|
||||
LayoutInflater layoutInflaterAndroid = LayoutInflater.from(getApplicationContext());
|
||||
@ -257,9 +233,11 @@ public class BlackList extends AppCompatActivity {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
private void handleAddUser(User user) {
|
||||
Toast.makeText(this, R.string.add_user_to_list, Snackbar.LENGTH_LONG).show();
|
||||
blacklistedUsersIDs.clear();
|
||||
blacklistedUsers.clear();
|
||||
blacklistedUsersIDs.addAll(user.getBlacklist());
|
||||
fetchBlackListedUsers();
|
||||
}
|
||||
|
||||
@ -280,18 +258,39 @@ public class BlackList extends AppCompatActivity {
|
||||
}
|
||||
|
||||
private void toggleEmptyNotes() {
|
||||
|
||||
if (didFetched && blacklistedUsers.size() == 0) {
|
||||
noNotesView.setVisibility(View.VISIBLE);
|
||||
noNotesView.setText(R.string.list_is_empty);
|
||||
loader.setVisibility(View.GONE);
|
||||
noNotesView.setVisibility(View.VISIBLE);
|
||||
}else if (blacklistedUsers.size() > 0) {
|
||||
noNotesView.setVisibility(View.GONE);
|
||||
loader.setVisibility(View.GONE);
|
||||
} else {
|
||||
loader.setVisibility(View.VISIBLE);
|
||||
noNotesView.setText(getString(R.string.loading));
|
||||
noNotesView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
disposable.dispose();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
@ -346,25 +345,4 @@ public class BlackList extends AppCompatActivity {
|
||||
},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();
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,6 @@ import com.uam.wmi.findmytutor.model.ValidateUser;
|
||||
import com.uam.wmi.findmytutor.network.ApiClient;
|
||||
import com.uam.wmi.findmytutor.service.LdapService;
|
||||
import com.uam.wmi.findmytutor.service.UserService;
|
||||
import com.uam.wmi.findmytutor.utils.MapUtils;
|
||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||
import com.uam.wmi.findmytutor.utils.RestApiHelper;
|
||||
|
||||
@ -150,9 +149,9 @@ 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)
|
||||
//disposable.add(ldapService.fakeValidate(fakeUser)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(this::handleResponse, this::handleError));
|
||||
@ -191,7 +190,6 @@ public class LoginActivity extends AppCompatActivity {
|
||||
|
||||
getUserProfile(userId.asString());
|
||||
|
||||
|
||||
Intent data = new Intent();
|
||||
String txt = "Main Activity";
|
||||
data.setData(Uri.parse(txt));
|
||||
|
@ -4,11 +4,9 @@ import android.Manifest;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.location.Location;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.PowerManager;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.text.TextUtils;
|
||||
@ -46,12 +44,12 @@ 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;
|
||||
|
||||
import com.uam.wmi.findmytutor.utils.EnableSharingDialog;
|
||||
import com.uam.wmi.findmytutor.utils.LocaleHelper;
|
||||
import com.uam.wmi.findmytutor.utils.LocaleUtils;
|
||||
|
||||
import com.uam.wmi.findmytutor.utils.ManualLocationUtils;
|
||||
import com.uam.wmi.findmytutor.utils.MapMarker;
|
||||
import com.uam.wmi.findmytutor.utils.MapUtils;
|
||||
@ -72,19 +70,17 @@ 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 {
|
||||
|
||||
private HashMap<Long, String> markerUserHash = new HashMap<>();
|
||||
private String tag = getClass().getName();
|
||||
private PermissionsManager permissionsManager;
|
||||
private LocationComponent locationComponent;
|
||||
private CoordinateService coordinateService;
|
||||
private UserService userService;
|
||||
|
||||
private CompositeDisposable disposable = new CompositeDisposable();
|
||||
private int mInterval = mapRefreshInterval;
|
||||
private int mInterval = 10000;
|
||||
private Handler mHandler = new Handler();
|
||||
private Runnable mStatusChecker;
|
||||
private MapView mapView;
|
||||
@ -93,8 +89,9 @@ public class MapActivity extends BaseActivity
|
||||
private Button removeLocationButton;
|
||||
private Marker tmpLocalMarker;
|
||||
private Coordinate droppedMarkercoordinate;
|
||||
public HashMap<String, Coordinate> coordsMap = new HashMap<>();
|
||||
private HashMap<String, Coordinate> coordsMap = new HashMap<>();
|
||||
private HashMap<String, MapMarker> markerHash = new HashMap<>();
|
||||
private HashMap<Long, String> markerUserHash = new HashMap<>();
|
||||
private Set<String> previousCoordsIds = new HashSet<>();
|
||||
private ManualLocationUtils manualLocationUtils;
|
||||
// Camera Animation params
|
||||
@ -106,11 +103,6 @@ public class MapActivity extends BaseActivity
|
||||
private ApproximatedLocalization approximatedLocalization;
|
||||
private boolean shouldFetchNewCoords = true;
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context base) {
|
||||
super.attachBaseContext(LocaleHelper.onAttach(base));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@ -127,7 +119,6 @@ public class MapActivity extends BaseActivity
|
||||
mStatusChecker = () -> {
|
||||
try {
|
||||
if (shouldFetchNewCoords) {
|
||||
checkIfUsesCanBeTutor();
|
||||
fetchTopCoords();
|
||||
}
|
||||
} finally {
|
||||
@ -136,6 +127,7 @@ public class MapActivity extends BaseActivity
|
||||
|
||||
};
|
||||
|
||||
|
||||
selectLocationButton = findViewById(R.id.select_location_button);
|
||||
removeLocationButton = findViewById(R.id.remove_location_button);
|
||||
mapView = findViewById(R.id.mapView);
|
||||
@ -146,11 +138,6 @@ public class MapActivity extends BaseActivity
|
||||
handleBackgroundTaskLifeCycle();
|
||||
manualLocationUtils = new ManualLocationUtils(MapActivity.this);
|
||||
approximatedLocalization = new ApproximatedLocalization(MapUtils.loadJsonFromAsset(getApplicationContext(), "building.geojson"));
|
||||
|
||||
if(isTutor){
|
||||
MapUtils.BatteryOptimizationsExceptionCheck(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -161,7 +148,22 @@ public class MapActivity extends BaseActivity
|
||||
|
||||
mapboxMap.setOnMarkerClickListener(marker -> {
|
||||
String id = markerUserHash.get(marker.getId());
|
||||
createMarkerModal(id);
|
||||
String locationLevel = PrefUtils.getLocationLevel(getApplicationContext());
|
||||
|
||||
/* if (id.equals(myId) && (locationLevel.equals(SharingLevel.MANUAL.toString()) || locationLevel.equals(SharingLevel.PREDEFINED.toString()))) {
|
||||
selectLocationButton.setVisibility(View.GONE);
|
||||
removeLocationButton.setVisibility(View.VISIBLE);
|
||||
|
||||
removeLocationButton.setOnClickListener(view -> {
|
||||
stopBackgroundLocalizationTask();
|
||||
|
||||
removeLocationButton.setVisibility(View.GONE);
|
||||
Toast.makeText(MapActivity.this, R.string.manual_marker_info, Toast.LENGTH_SHORT).show();
|
||||
|
||||
});
|
||||
} else {*/
|
||||
createMarkerModal(id);
|
||||
/* }*/
|
||||
|
||||
return true;
|
||||
});
|
||||
@ -214,28 +216,13 @@ public class MapActivity extends BaseActivity
|
||||
|
||||
userName.setText(String.format("%s %s", user.getFirstName(), user.getLastName()));
|
||||
|
||||
if (cordStatus.equals("")) {
|
||||
if(cordStatus.equals("")){
|
||||
status.setText(String.format("%s: %s", getResources().getString(R.string.status_switch_title), getString(R.string.lack_of_status)));
|
||||
} else {
|
||||
}else{
|
||||
status.setText(String.format("%s: %s", getResources().getString(R.string.status_switch_title), cordStatus));
|
||||
}
|
||||
|
||||
String sharingLevelToRender = sharingLevel;
|
||||
Log.e("LOCALE",PrefUtils.getLocale(getApplicationContext()));
|
||||
|
||||
if (PrefUtils.getLocale(getApplicationContext()).equals("pl") ||
|
||||
PrefUtils.getLocale(getApplicationContext()).equals("pl-PL") ||
|
||||
PrefUtils.getLocale(getApplicationContext()).equals("[pl-PL]")) {
|
||||
if (sharingLevel.equals(SharingLevel.MANUAL.toString())) {
|
||||
sharingLevelToRender = getString(R.string.manual_mode);
|
||||
} else if (sharingLevel.equals(SharingLevel.EXACT.toString())) {
|
||||
sharingLevelToRender = getString(R.string.exact_mode);
|
||||
} else if (sharingLevel.equals(SharingLevel.APPROXIMATED.toString())) {
|
||||
sharingLevelToRender = getString(R.string.approx_mode);
|
||||
}
|
||||
}
|
||||
|
||||
sharingLevelView.setText(String.format("%s: %s", getResources().getString(R.string.settings_location_level), sharingLevelToRender));
|
||||
sharingLevelView.setText(String.format("%s: %s", getResources().getString(R.string.settings_location_level), sharingLevel));
|
||||
|
||||
final AlertDialog alertDialog = alertDialogBuilderUserInput.create();
|
||||
alertDialog.show();
|
||||
@ -259,12 +246,7 @@ Log.e("LOCALE",PrefUtils.getLocale(getApplicationContext()));
|
||||
}
|
||||
|
||||
private void setOnMapClickListener() {
|
||||
|
||||
mapboxMap.addOnMapClickListener(e -> {
|
||||
removeLocationButton.setVisibility(View.GONE);
|
||||
selectLocationButton.setVisibility(View.GONE);
|
||||
restoreMapMarkers();
|
||||
});
|
||||
mapboxMap.addOnMapClickListener(e -> removeLocationButton.setVisibility(View.GONE));
|
||||
}
|
||||
|
||||
private void setOnMapLongClickListener() {
|
||||
@ -358,7 +340,7 @@ Log.e("LOCALE",PrefUtils.getLocale(getApplicationContext()));
|
||||
Button dismissButton = alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE);
|
||||
|
||||
dismissButton.setOnClickListener(view1 -> {
|
||||
PrefUtils.putCurrentManualLocationName(getApplicationContext(), getString(R.string.other_location));
|
||||
PrefUtils.putCurrentManualLocationName(getApplicationContext(), "Inne");
|
||||
PrefUtils.putCurrentManualLocation(getApplicationContext(), "-1");
|
||||
|
||||
alertDialog.dismiss();
|
||||
@ -383,7 +365,7 @@ Log.e("LOCALE",PrefUtils.getLocale(getApplicationContext()));
|
||||
|
||||
|
||||
private void sendLocation(String body, LatLng latLng) {
|
||||
PredefinedCoordinatesService predefinedCoordinatesService = ApiClient.getClient(getApplicationContext()).create(PredefinedCoordinatesService.class);
|
||||
PredefinedStatusesService predefinedStatusesService = ApiClient.getClient(getApplicationContext()).create(PredefinedStatusesService.class);
|
||||
|
||||
PredefinedCoordViewModel droppedMarkercoordinate = new PredefinedCoordViewModel(
|
||||
latLng.getLatitude(),
|
||||
@ -397,7 +379,7 @@ Log.e("LOCALE",PrefUtils.getLocale(getApplicationContext()));
|
||||
|
||||
CompositeDisposable disposable = new CompositeDisposable();
|
||||
disposable.add(
|
||||
predefinedCoordinatesService.postUserPredefinedCoord(PrefUtils.getUserId(getApplicationContext()), droppedMarkercoordinate)
|
||||
predefinedStatusesService.postUserPredefinedCoord(PrefUtils.getUserId(getApplicationContext()), droppedMarkercoordinate)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(this::SaveCurrentManualLocation, this::handleError)
|
||||
@ -409,30 +391,6 @@ Log.e("LOCALE",PrefUtils.getLocale(getApplicationContext()));
|
||||
PrefUtils.putCurrentManualLocation(getApplicationContext(), resp.getPredefinedCoordinateId());
|
||||
}
|
||||
|
||||
|
||||
private void checkIfUsesCanBeTutor(){
|
||||
disposable.add(
|
||||
userService.getSelf(myId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeWith(new DisposableSingleObserver<User>() {
|
||||
@Override
|
||||
public void onSuccess(User user) {
|
||||
boolean tutorFromBackend = user.getTitle().equals("tutor");
|
||||
|
||||
if(tutorFromBackend != PrefUtils.getIsTutor(getApplicationContext())){
|
||||
logout();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
showError(e);
|
||||
}
|
||||
}));
|
||||
|
||||
}
|
||||
|
||||
private void fetchTopCoords() {
|
||||
|
||||
disposable.add(
|
||||
@ -645,6 +603,47 @@ Log.e("LOCALE",PrefUtils.getLocale(getApplicationContext()));
|
||||
}
|
||||
}
|
||||
|
||||
// Add the mapView lifecycle to the activity's lifecycle methods
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
mapView.onResume();
|
||||
shouldFetchNewCoords = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
mapView.onStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
mapView.onStop();
|
||||
shouldFetchNewCoords = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
mapView.onPause();
|
||||
shouldFetchNewCoords = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLowMemory() {
|
||||
super.onLowMemory();
|
||||
mapView.onLowMemory();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mapView.onDestroy();
|
||||
mHandler.removeCallbacks(mStatusChecker);
|
||||
disposable.dispose();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
@ -687,13 +686,11 @@ Log.e("LOCALE",PrefUtils.getLocale(getApplicationContext()));
|
||||
@Override
|
||||
public void searchUser(String textToSearch) {
|
||||
getUserFromApi(textToSearch);
|
||||
|
||||
Log.e("LOCALE", LocaleUtils.getCurrentLocale());
|
||||
}
|
||||
|
||||
private void getUserFromApi(String userNameToSearch) {
|
||||
disposable.add(
|
||||
userService.getAllOnlineTutors()
|
||||
userService.getAllTutors()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.map(tutors -> Stream.of(tutors).filter(t ->
|
||||
@ -701,7 +698,6 @@ Log.e("LOCALE",PrefUtils.getLocale(getApplicationContext()));
|
||||
.subscribeWith(new DisposableSingleObserver<List<User>>() {
|
||||
@Override
|
||||
public void onSuccess(List<User> users) {
|
||||
Log.e("USERS", String.valueOf(users));
|
||||
filterMarkers(users);
|
||||
}
|
||||
|
||||
@ -712,7 +708,7 @@ Log.e("LOCALE",PrefUtils.getLocale(getApplicationContext()));
|
||||
}));
|
||||
}
|
||||
|
||||
public void filterMarkers(List<User> users) {
|
||||
private void filterMarkers(List<User> users) {
|
||||
restoreMapMarkers();
|
||||
|
||||
Icon markedMarker = IconFactory.getInstance(MapActivity.this).fromResource(R.drawable.search_marker);
|
||||
@ -733,65 +729,19 @@ Log.e("LOCALE",PrefUtils.getLocale(getApplicationContext()));
|
||||
}
|
||||
|
||||
public void restoreMapMarkers() {
|
||||
try {
|
||||
for (Marker marker : mapboxMap.getMarkers()) {
|
||||
MapMarker markerMap = markerHash.get(markerUserHash.get(marker.getId()));
|
||||
|
||||
markerMap.restoreDefaultIcon();
|
||||
mapboxMap.deselectMarker(marker);
|
||||
}
|
||||
for (Marker marker : mapboxMap.getMarkers()) {
|
||||
MapMarker markerMap = markerHash.get(markerUserHash.get(marker.getId()));
|
||||
|
||||
mapboxMap.getMarkerViewManager().update();
|
||||
} catch (Exception e) {
|
||||
Log.e("MAP", String.valueOf(e));
|
||||
markerMap.restoreDefaultIcon();
|
||||
mapboxMap.deselectMarker(marker);
|
||||
}
|
||||
|
||||
mapboxMap.getMarkerViewManager().update();
|
||||
}
|
||||
|
||||
public void adjustMapToSearch(Integer zoom) {
|
||||
MapUtils.setZoom(mapboxMap, zoom);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
mapView.onResume();
|
||||
shouldFetchNewCoords = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
mapView.onStart();
|
||||
shouldFetchNewCoords = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
mapView.onStop();
|
||||
shouldFetchNewCoords = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
mapView.onPause();
|
||||
shouldFetchNewCoords = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLowMemory() {
|
||||
super.onLowMemory();
|
||||
mapView.onLowMemory();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mapView.onDestroy();
|
||||
mHandler.removeCallbacks(mStatusChecker);
|
||||
disposable.dispose();
|
||||
}
|
||||
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
package com.uam.wmi.findmytutor.activity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
@ -16,15 +15,12 @@ import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import com.uam.wmi.findmytutor.R;
|
||||
import com.uam.wmi.findmytutor.utils.LocaleHelper;
|
||||
import com.uam.wmi.findmytutor.utils.LocaleUtils;
|
||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
|
||||
|
||||
public class SettingsActivity extends AppCompatPreferenceActivity {
|
||||
private static final String TAG = SettingsActivity.class.getSimpleName();
|
||||
|
||||
@ -37,15 +33,9 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
||||
getFragmentManager().beginTransaction().replace(android.R.id.content, new MainPreferenceFragment()).commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context base) {
|
||||
super.attachBaseContext(LocaleHelper.onAttach(base));
|
||||
}
|
||||
|
||||
public void setLocale(String localeName) {
|
||||
Context context = LocaleHelper.setLocale(this, localeName);
|
||||
Resources res = context.getResources();
|
||||
Locale myLocale = new Locale(localeName);
|
||||
Resources res = getResources();
|
||||
DisplayMetrics dm = res.getDisplayMetrics();
|
||||
Configuration conf = res.getConfiguration();
|
||||
conf.locale = myLocale;
|
||||
@ -72,12 +62,9 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
||||
languagesList.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
|
||||
if (!newValue.toString().equals("0")){
|
||||
LocaleHelper.setLocale(getActivity(), "pl");
|
||||
((SettingsActivity)getActivity()).setLocale("pl");
|
||||
PrefUtils.storeLocale(getActivity(),"pl");
|
||||
LocaleHelper.setLocale(getActivity(), "pl");
|
||||
}else{
|
||||
LocaleHelper.setLocale(getActivity(), "en");
|
||||
((SettingsActivity)getActivity()).setLocale("en");
|
||||
PrefUtils.storeLocale(getActivity(),"en");
|
||||
}
|
||||
|
@ -1,10 +1,7 @@
|
||||
package com.uam.wmi.findmytutor.activity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.FragmentTransaction;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.preference.ListPreference;
|
||||
@ -24,17 +21,15 @@ import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
|
||||
import com.uam.wmi.findmytutor.R;
|
||||
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.LocaleHelper;
|
||||
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 java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@ -50,27 +45,17 @@ 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;
|
||||
protected List<PredefinedCoordViewModel> predefinedCoordsList = new ArrayList<>();
|
||||
private HashMap<String, String> locationMap;
|
||||
private ArrayList<String> locationUUIDs;
|
||||
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() {
|
||||
return new SharingFragment();
|
||||
@ -84,13 +69,7 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
||||
.subscribeWith(new DisposableSingleObserver<List<String>>() {
|
||||
@Override
|
||||
public void onSuccess(List<String> strings) {
|
||||
statusesArray = strings.toArray(new String[strings.size()]);
|
||||
if (strings.isEmpty()) {
|
||||
disableStatusPreferences();
|
||||
} else {
|
||||
enableStatusPreferences();
|
||||
}
|
||||
// Log.d("STATUSES",Integer.toString(statusesArray.length ));
|
||||
String[] statusesArray = strings.toArray(new String[strings.size()]);
|
||||
setListPreferenceData(statusList, statusesArray, null);
|
||||
}
|
||||
|
||||
@ -103,48 +82,29 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
||||
}
|
||||
|
||||
void getLocations(CompositeDisposable disposable) {
|
||||
disposable.add(locationService.getUserPredefinedCoords(PrefUtils.getUserId(getApplicationContext()))
|
||||
disposable.add(statusesService.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());
|
||||
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);
|
||||
if (!PrefUtils.getLocationLevel(getApplicationContext()).equals("manual")) {
|
||||
preferenceCategory.removePreference(manualLocationList);
|
||||
preferenceCategory.removePreference(removeManualLocation);
|
||||
preferenceCategory.removePreference(manualLocationButton);
|
||||
} else {
|
||||
if (!predefinedCoordsList.isEmpty()) {
|
||||
|
||||
manualLocationList.setEnabled(true);
|
||||
manualLocationList.setSummary(PrefUtils.getCurrentManualLocationName(getApplicationContext()));
|
||||
removeManualLocation.setEnabled(true);
|
||||
locationSharing.setEnabled(true);
|
||||
}
|
||||
}
|
||||
List<String> predefinedLocationsNames = Stream.of(coords).map(PredefinedCoordViewModel::getName).toList();
|
||||
predefinedCoordsList.addAll(coords);
|
||||
|
||||
String[] stringnames = predefinedLocationsNames.toArray(new String[0]);
|
||||
predefinedLocationsList = new ArrayList<>(Arrays.asList(stringnames));
|
||||
|
||||
List<Integer> activesId = Stream.of(coords).indexed()
|
||||
.filter(v -> v.getSecond().getPredefinedCoordinateId().equals(currentCoordId)).map(IntPair::getFirst).toList();
|
||||
|
||||
if (activesId.size() == 0) {
|
||||
if( activesId.size() == 0){
|
||||
setListPreferenceData(manualLocationList, stringnames, null);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
setListPreferenceData(manualLocationList, stringnames, activesId.get(0));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -154,28 +114,20 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@SuppressLint("ResourceType")
|
||||
@Override
|
||||
public void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.pref_sharing);
|
||||
addPreferencesFromResource(R.layout.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);
|
||||
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>();
|
||||
@ -192,7 +144,6 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
||||
statusList.setSummary(PrefUtils.getUserStatus(getApplicationContext()));
|
||||
manualLocationList.setSummary(PrefUtils.getCurrentManualLocationName(getApplicationContext()));
|
||||
|
||||
|
||||
/** Main sharing switch**/
|
||||
locationSharing.setOnPreferenceChangeListener((buttonView, newValue) -> {
|
||||
PrefUtils.storeEnableSharingLocalization(getApplicationContext(), (Boolean) newValue);
|
||||
@ -204,25 +155,28 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
||||
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(removeManualLocation);
|
||||
}
|
||||
|
||||
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) -> {
|
||||
@ -245,15 +199,16 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
||||
return true;
|
||||
});
|
||||
|
||||
|
||||
|
||||
/** Button 'choose from map' button listener **/
|
||||
manualLocationButton.setOnPreferenceChangeListener((preference, o) -> {
|
||||
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
|
||||
fragmentTransaction.hide(SharingFragment.this);
|
||||
fragmentTransaction.commit();
|
||||
((MapActivity) getActivity()).updateNavigationBarState();
|
||||
return true;
|
||||
});
|
||||
statusSwitch.setOnPreferenceChangeListener((preference, newValue) -> true);
|
||||
|
||||
/** Status list change listener **/
|
||||
statusList.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
ListPreference lp = (ListPreference) preference;
|
||||
@ -262,17 +217,8 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
||||
lp.setSummary(entries[Integer.parseInt((String) newValue)]);
|
||||
return true;
|
||||
});
|
||||
statusList.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
|
||||
if (statusesArray.length == 0) {
|
||||
builder.setTitle("nie ma wody na pustyni");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
/** Custom status edittext change listener **/
|
||||
/** Custom status list change listener **/
|
||||
manualStatus.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
|
||||
disposable.add(statusesService.postUserPredefinedStatus(PrefUtils.getUserId(getApplicationContext()), (String) newValue)
|
||||
@ -282,41 +228,6 @@ 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
|
||||
@ -327,36 +238,6 @@ 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 {
|
||||
@ -382,15 +263,10 @@ 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()));
|
||||
@ -408,83 +284,11 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
||||
}
|
||||
}
|
||||
|
||||
private void handleDeleteStatuses(List<String> resp) {
|
||||
if (resp.isEmpty()) {
|
||||
disableStatusPreferences();
|
||||
} else {
|
||||
String[] statusesArray = resp.toArray(new String[resp.size()]);
|
||||
setListPreferenceData(statusList, statusesArray, null);
|
||||
String currentEntry = PrefUtils.getUserStatus(getApplicationContext());
|
||||
if (resp.contains(currentEntry)) {
|
||||
statusList.setValueIndex(resp.indexOf(currentEntry));
|
||||
} else {
|
||||
statusList.setValueIndex(0);
|
||||
statusList.setSummary(resp.get(0));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void handleDeleteLocations(List<PredefinedCoordViewModel> resp) {
|
||||
getLocations(disposable);
|
||||
String currentEntry = PrefUtils.getCurrentManualLocation(getApplicationContext());
|
||||
if (resp.isEmpty()) {
|
||||
disableManualLocationPreferences();
|
||||
} else {
|
||||
if (!Stream.of(resp).filter(x -> x.getName().equals(currentEntry)).toList().isEmpty()) {
|
||||
for (PredefinedCoordViewModel location : resp) {
|
||||
if (location.getName().equals(currentEntry)) {
|
||||
manualLocationList.setValueIndex(resp.indexOf(location));
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
manualLocationList.setValueIndex(0);
|
||||
manualLocationList.setSummary(resp.get(0).getName());
|
||||
//todo czy na pewno w shared pref sa dobre wartosci
|
||||
}
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||
locationSharing.setChecked(PrefUtils.isEnableSharingLocalization(getApplicationContext()));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void disableStatusPreferences() {
|
||||
removeManualStatus.setEnabled(false);
|
||||
statusList.setEnabled(false);
|
||||
statusSwitch.setEnabled(false);
|
||||
statusList.setSummary("");
|
||||
PrefUtils.disableStatus(getApplicationContext());
|
||||
|
||||
}
|
||||
|
||||
private void enableStatusPreferences() {
|
||||
removeManualStatus.setEnabled(true);
|
||||
statusList.setEnabled(true);
|
||||
statusSwitch.setEnabled(true);
|
||||
statusList.setSummary(PrefUtils.getUserStatus(getApplicationContext()));
|
||||
}
|
||||
|
||||
private void disableManualLocationPreferences() {
|
||||
removeManualLocation.setEnabled(false);
|
||||
manualLocationList.setEnabled(false);
|
||||
manualLocationList.setSummary("");
|
||||
locationSharing.setChecked(false);
|
||||
locationSharing.setEnabled(false);
|
||||
PrefUtils.disableSharing(getApplicationContext());
|
||||
((MapActivity) getActivity()).handleBackgroundTaskLifeCycle();
|
||||
|
||||
}
|
||||
|
||||
private void enableManualLocationPreferences() {
|
||||
removeManualLocation.setEnabled(true);
|
||||
manualLocationList.setEnabled(true);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||
locationSharing.setChecked(PrefUtils.isEnableSharingLocalization(getApplicationContext()));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
@ -498,11 +302,4 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
||||
getPreferenceManager().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
disposable.dispose();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,29 +1,15 @@
|
||||
package com.uam.wmi.findmytutor.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.PowerManager;
|
||||
import android.provider.Settings;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
||||
import com.uam.wmi.findmytutor.R;
|
||||
import com.uam.wmi.findmytutor.utils.LocaleHelper;
|
||||
import com.uam.wmi.findmytutor.utils.MapUtils;
|
||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||
|
||||
import java.util.Locale;
|
||||
@ -32,11 +18,6 @@ public class StartupActivity extends AppCompatActivity {
|
||||
private static final int AUTHENTICATION_REQUEST_CODE = 666;
|
||||
String currentLang;
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context base) {
|
||||
super.attachBaseContext(LocaleHelper.onAttach(base));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
@ -50,10 +31,10 @@ public class StartupActivity extends AppCompatActivity {
|
||||
} else {
|
||||
Intent loginIntent = new Intent(this, LoginActivity.class);
|
||||
startActivityForResult(loginIntent, AUTHENTICATION_REQUEST_CODE);
|
||||
|
||||
}
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -66,8 +47,4 @@ public class StartupActivity extends AppCompatActivity {
|
||||
|
||||
finish();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,49 +0,0 @@
|
||||
package com.uam.wmi.findmytutor.activity;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Dialog;
|
||||
import android.app.DialogFragment;
|
||||
import android.app.TimePickerDialog;
|
||||
import android.os.Bundle;
|
||||
import android.text.format.DateFormat;
|
||||
import android.widget.TextView;
|
||||
import android.widget.TimePicker;
|
||||
|
||||
import com.uam.wmi.findmytutor.model.DutyHourViewModel;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
@SuppressLint("ValidFragment")
|
||||
public class TimePickerFragment extends DialogFragment
|
||||
implements TimePickerDialog.OnTimeSetListener {
|
||||
private TextView textView;
|
||||
private String field;
|
||||
private DutyHourViewModel duty;
|
||||
@SuppressLint("ValidFragment")
|
||||
public TimePickerFragment(TextView view, DutyHourViewModel duty, String field){
|
||||
this.textView = view;
|
||||
this.duty=duty;
|
||||
this.field=field;
|
||||
}
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
// Use the current time as the default values for the picker
|
||||
final Calendar c = Calendar.getInstance();
|
||||
int hour = c.get(Calendar.HOUR_OF_DAY);
|
||||
int minute = c.get(Calendar.MINUTE);
|
||||
|
||||
// Create a new instance of TimePickerDialog and return it
|
||||
return new TimePickerDialog(getActivity(), this, hour, minute,
|
||||
DateFormat.is24HourFormat(getActivity()));
|
||||
}
|
||||
|
||||
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
|
||||
String time = String.format("%d:%02d",hourOfDay,minute);
|
||||
textView.setText(time);
|
||||
if(field.equals("start")){
|
||||
duty.setStart(time);
|
||||
}else{
|
||||
duty.setEnd(time);
|
||||
}
|
||||
// Do something with the time chosen by the user
|
||||
}
|
||||
}
|
@ -1,21 +1,14 @@
|
||||
package com.uam.wmi.findmytutor.activity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.TextInputEditText;
|
||||
import android.support.design.widget.TextInputLayout;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.PopupWindow;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
@ -28,22 +21,22 @@ 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.LocaleHelper;
|
||||
import com.uam.wmi.findmytutor.utils.InfoHelperUtils;
|
||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||
import com.uam.wmi.findmytutor.utils.RestApiHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
import io.reactivex.observers.DisposableCompletableObserver;
|
||||
import io.reactivex.observers.DisposableSingleObserver;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.ResponseBody;
|
||||
import retrofit2.Response;
|
||||
|
||||
import static java.lang.String.valueOf;
|
||||
|
||||
public class TutorTab extends AppCompatActivity {
|
||||
@ -68,21 +61,16 @@ 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);
|
||||
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
toolbar.setTitle(R.string.profile_activity_title);
|
||||
setSupportActionBar(toolbar);
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.content_tutor_tab);
|
||||
|
||||
userName = findViewById(R.id.userName);
|
||||
userNote = findViewById(R.id.userNote);
|
||||
userNote = (TextInputEditText) findViewById(R.id.userNote);
|
||||
userRoom = findViewById(R.id.userRoom);
|
||||
userEmail = findViewById(R.id.userEmail);
|
||||
department = findViewById(R.id.userDepartment);
|
||||
saveButon = findViewById(R.id.saveButton);
|
||||
saveButon = findViewById(R.id.saveButon);
|
||||
scrapButton = findViewById(R.id.scrapTutorTab);
|
||||
addDutyButton = findViewById(R.id.addDuty);
|
||||
dutyHoursRecycller = findViewById(R.id.dutyHourView);
|
||||
@ -96,6 +84,8 @@ public class TutorTab extends AppCompatActivity {
|
||||
|
||||
getTutorTab();
|
||||
|
||||
findViewById(R.id.contentTutorTabInfoImageButton).setOnClickListener(v-> InfoHelperUtils.infoPopUp(v,R.layout.info_popup_tutor_tab));
|
||||
|
||||
userName.setText(String.format("%s %s", PrefUtils.getUserFirstName(getApplicationContext()), PrefUtils.getUserLastName(getApplicationContext())));
|
||||
|
||||
disposable.add(
|
||||
@ -120,34 +110,6 @@ public class TutorTab extends AppCompatActivity {
|
||||
scrapButton.setOnClickListener(view -> scrapTutorTab());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.menu_profile, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
if (item.getItemId()==R.id.action_profile_info_popup){
|
||||
int layoutID = R.layout.info_popup_tutor_tab;
|
||||
|
||||
View popupView = getLayoutInflater().inflate(layoutID,null);
|
||||
|
||||
PopupWindow popupWindow = new PopupWindow(popupView,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
// If the PopupWindow should be focusable
|
||||
popupWindow.setFocusable(true);
|
||||
// If you need the PopupWindow to dismiss when when touched outside
|
||||
popupWindow.setBackgroundDrawable(new ColorDrawable());
|
||||
// Get the View's(the one that was clicked in the Fragment) location
|
||||
View anchorView= getWindow().getDecorView().findViewById(android.R.id.content);
|
||||
popupWindow.showAtLocation(anchorView,Gravity.TOP|Gravity.END, 0, 0);
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
private void getTutorTab(){
|
||||
disposable.add(
|
||||
tutorTabService.apiUsersTutorTabByTutorIdGet(PrefUtils.getUserId(getApplicationContext()))
|
||||
@ -159,7 +121,7 @@ public class TutorTab extends AppCompatActivity {
|
||||
|
||||
dutyHourList = tutorTabViewModel.getDutyHours();
|
||||
if(dutyHourList != null){
|
||||
dutyHoursAdapter = new DutyHoursAdapter(getApplicationContext(),dutyHourList, getFragmentManager());
|
||||
dutyHoursAdapter = new DutyHoursAdapter(getApplicationContext(),dutyHourList);
|
||||
dutyHoursRecycller.setAdapter(dutyHoursAdapter);
|
||||
addDutyButton.setOnClickListener(v -> addEmptyDuty(dutyHoursAdapter));
|
||||
}
|
||||
@ -172,21 +134,17 @@ public class TutorTab extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
int code = 0;
|
||||
|
||||
if (e instanceof HttpException) {
|
||||
code = ((HttpException) e).response().code();
|
||||
}
|
||||
|
||||
int code = ((HttpException) e).response().code();
|
||||
if( code == 404){
|
||||
ifTutorTabExists = false;
|
||||
dutyHoursAdapter = new DutyHoursAdapter(getApplicationContext(),new ArrayList<DutyHourViewModel>(), getFragmentManager());
|
||||
dutyHoursAdapter = new DutyHoursAdapter(getApplicationContext(),new ArrayList<DutyHourViewModel>());
|
||||
dutyHoursRecycller.setAdapter(dutyHoursAdapter);
|
||||
addDutyButton.setOnClickListener(v -> addEmptyDuty(dutyHoursAdapter));
|
||||
}
|
||||
showError(e);
|
||||
}
|
||||
}));
|
||||
|
||||
}
|
||||
|
||||
private void addEmptyDuty(DutyHoursAdapter adapter){
|
||||
@ -197,20 +155,16 @@ public class TutorTab extends AppCompatActivity {
|
||||
|
||||
private void setUpSaveListener(Button button) {
|
||||
button.setOnClickListener(view -> {
|
||||
if( isEmailValid(userEmail.getText().toString())){
|
||||
newTab = new TutorTabViewModel(PrefUtils.getUserId(getApplicationContext()),
|
||||
userRoom.getText().toString(),
|
||||
userEmail.getText().toString(),
|
||||
userNote.getText().toString(),
|
||||
dutyHoursAdapter.getDutyList());
|
||||
if(ifTutorTabExists){
|
||||
putUserTab(newTab);
|
||||
}else{
|
||||
postUserTab(newTab);
|
||||
ifTutorTabExists=true;
|
||||
}
|
||||
newTab = new TutorTabViewModel(PrefUtils.getUserId(getApplicationContext()),
|
||||
userRoom.getText().toString(),
|
||||
userEmail.getText().toString(),
|
||||
userNote.getText().toString(),
|
||||
dutyHoursAdapter.getDutyList());
|
||||
if(ifTutorTabExists){
|
||||
putUserTab(newTab);
|
||||
}else{
|
||||
userEmail.setError(getString(R.string.error_invalid_email));
|
||||
postUserTab(newTab);
|
||||
ifTutorTabExists=true;
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -261,6 +215,7 @@ public class TutorTab extends AppCompatActivity {
|
||||
Toast.makeText(getApplicationContext(),
|
||||
"Network error " + error.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
|
||||
|
||||
Log.e("WMI SUCC", String.valueOf(error));
|
||||
|
||||
}
|
||||
@ -278,26 +233,4 @@ public class TutorTab extends AppCompatActivity {
|
||||
Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context base) {
|
||||
super.attachBaseContext(LocaleHelper.onAttach(base));
|
||||
}
|
||||
|
||||
public boolean isEmailValid(String email)
|
||||
{
|
||||
String regExpn =
|
||||
"^(([\\w-]+\\.)+[\\w-]+|([a-zA-Z]{1}|[\\w-]{2,}))@"
|
||||
+"((([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\\.([0-1]?"
|
||||
+"[0-9]{1,2}|25[0-5]|2[0-4][0-9])\\."
|
||||
+"([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\\.([0-1]?"
|
||||
+"[0-9]{1,2}|25[0-5]|2[0-4][0-9])){1}|"
|
||||
+"([a-zA-Z]+[\\w-]+\\.)+[a-zA-Z]{2,4})$";
|
||||
|
||||
CharSequence inputStr = email;
|
||||
|
||||
Pattern pattern = Pattern.compile(regExpn,Pattern.CASE_INSENSITIVE);
|
||||
Matcher matcher = pattern.matcher(inputStr);
|
||||
|
||||
return matcher.matches();
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,7 @@
|
||||
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.os.SystemClock;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.design.widget.CoordinatorLayout;
|
||||
import android.support.design.widget.Snackbar;
|
||||
@ -12,11 +9,6 @@ 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.format.DateFormat;
|
||||
import android.text.style.ImageSpan;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
@ -26,24 +18,20 @@ import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
import com.github.ybq.android.spinkit.SpinKitView;
|
||||
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
|
||||
import com.uam.wmi.findmytutor.R;
|
||||
import com.uam.wmi.findmytutor.adapters.TutorsListAdapter;
|
||||
import com.uam.wmi.findmytutor.model.Coordinate;
|
||||
|
||||
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.CoordinateService;
|
||||
import com.uam.wmi.findmytutor.service.TutorTabApi;
|
||||
import com.uam.wmi.findmytutor.service.UserService;
|
||||
import com.uam.wmi.findmytutor.utils.ActiveFragment;
|
||||
import com.uam.wmi.findmytutor.utils.MyDividerItemDecoration;
|
||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||
import com.uam.wmi.findmytutor.utils.RecyclerTouchListener;
|
||||
@ -51,21 +39,14 @@ import com.uam.wmi.findmytutor.utils.RestApiHelper;
|
||||
|
||||
import java.text.Collator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.ObservableSource;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.functions.Function;
|
||||
import io.reactivex.observers.DisposableObserver;
|
||||
import io.reactivex.observers.DisposableSingleObserver;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.ResponseBody;
|
||||
@ -81,18 +62,13 @@ public class UsersListFragment extends Fragment {
|
||||
RecyclerView recyclerView;
|
||||
@BindView(R.id.txt_empty_notes_view)
|
||||
TextView noNotesView;
|
||||
@BindView(R.id.loader)
|
||||
SpinKitView loader;
|
||||
|
||||
private SearchView searchView;
|
||||
private UserService userService;
|
||||
private TutorTabApi tutorTabService;
|
||||
private CoordinateService coordinateService;
|
||||
private CompositeDisposable disposable = new CompositeDisposable();
|
||||
private TutorsListAdapter mAdapter;
|
||||
private List<User> tutorsList = new ArrayList<>();
|
||||
private HashMap<String, String> tutorsTimeStamps = new HashMap<>();
|
||||
|
||||
private List<User> tutorsFiltered = new ArrayList<>();
|
||||
private Collator plCollator = Collator.getInstance(Locale.forLanguageTag("pl-PL"));
|
||||
private Boolean fetchOnlyOnlineUsers = PrefUtils.getShowOnlyOnlineUsers(getApplicationContext());
|
||||
|
||||
@ -104,7 +80,7 @@ public class UsersListFragment extends Fragment {
|
||||
}
|
||||
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
mAdapter = new TutorsListAdapter(getActivity().getApplicationContext(), tutorsList, tutorsTimeStamps);
|
||||
mAdapter = new TutorsListAdapter(getActivity().getApplicationContext(), tutorsFiltered);
|
||||
View view = inflater.inflate(R.layout.users_list, container, false);
|
||||
view.setBackgroundColor(getResources().getColor(android.R.color.white));
|
||||
setHasOptionsMenu(true);
|
||||
@ -116,10 +92,9 @@ public class UsersListFragment extends Fragment {
|
||||
|
||||
userService = ApiClient.getClient(getApplicationContext())
|
||||
.create(UserService.class);
|
||||
|
||||
tutorTabService = ApiClient.getClient(getActivity().getApplicationContext())
|
||||
.create(TutorTabApi.class);
|
||||
coordinateService = ApiClient.getClient(getApplicationContext())
|
||||
.create(CoordinateService.class);
|
||||
|
||||
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getActivity());
|
||||
recyclerView.setLayoutManager(mLayoutManager);
|
||||
@ -127,16 +102,14 @@ public class UsersListFragment extends Fragment {
|
||||
recyclerView.setVerticalScrollBarEnabled(true);
|
||||
recyclerView.addItemDecoration(new MyDividerItemDecoration(getActivity(), LinearLayoutManager.VERTICAL, 16));
|
||||
recyclerView.setAdapter(mAdapter);
|
||||
noNotesView.setVisibility(View.GONE);
|
||||
|
||||
fetchAllTutors();
|
||||
fetchTopCords();
|
||||
|
||||
recyclerView.addOnItemTouchListener(new RecyclerTouchListener(getActivity().getApplicationContext(),
|
||||
recyclerView, new RecyclerTouchListener.ClickListener() {
|
||||
@Override
|
||||
public void onClick(View view, final int position) {
|
||||
showNoteDialog(tutorsList.get(position));
|
||||
showNoteDialog(tutorsFiltered.get(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -147,12 +120,14 @@ public class UsersListFragment extends Fragment {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onPrepareOptionsMenu(Menu menu) {
|
||||
super.onPrepareOptionsMenu(menu);
|
||||
try {
|
||||
menu.findItem(R.id.showOnlineUsersOnly).setChecked(fetchOnlyOnlineUsers);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.e(TAG, "onPrepareOptionsMenu error");
|
||||
}
|
||||
}
|
||||
@ -160,13 +135,13 @@ public class UsersListFragment extends Fragment {
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
//item.setChecked(fetchOnlyOnlineUsers);
|
||||
switch (item.getItemId()) {
|
||||
switch (item.getItemId()){
|
||||
case R.id.showOnlineUsersOnly:
|
||||
|
||||
if (item.isChecked()) {
|
||||
if(item.isChecked()) {
|
||||
fetchOnlyOnlineUsers = false;
|
||||
item.setChecked(false);
|
||||
} else {
|
||||
}else{
|
||||
item.setChecked(true);
|
||||
fetchOnlyOnlineUsers = true;
|
||||
}
|
||||
@ -183,11 +158,7 @@ public class UsersListFragment extends Fragment {
|
||||
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);
|
||||
super.onCreateOptionsMenu(menu,inflater);
|
||||
}
|
||||
|
||||
public void searchUser(String textToSearch) {
|
||||
@ -205,7 +176,6 @@ 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);
|
||||
@ -213,30 +183,9 @@ public class UsersListFragment extends Fragment {
|
||||
TextView userRoom = view.findViewById(R.id.userRoom);
|
||||
TextView userEmail = view.findViewById(R.id.userEmail);
|
||||
TextView department = view.findViewById(R.id.userDepartment);
|
||||
TextView userStatusLabel = view.findViewById(R.id.user_status_label);
|
||||
LinearLayout userStatusLabelLL = view.findViewById(R.id.user_status_label_linearLayout);
|
||||
|
||||
|
||||
|
||||
userName.setText(String.format("%s %s", user.getFirstName(), user.getLastName()));
|
||||
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())
|
||||
@ -244,21 +193,7 @@ public class UsersListFragment extends Fragment {
|
||||
.subscribeWith(new DisposableSingleObserver<TutorTabViewModel>() {
|
||||
@Override
|
||||
public void onSuccess(TutorTabViewModel tutorTabViewModel) {
|
||||
final AlertDialog alertDialog;
|
||||
if (((MapActivity) getActivity()).coordsMap.containsKey(user.getId())) {
|
||||
|
||||
alertDialogBuilderUserInput.setPositiveButton(R.string.show_on_map, (dialog, id) -> {
|
||||
// User cancelled the dialog
|
||||
((MapActivity) getActivity()).activeFragment = ActiveFragment.NONE;
|
||||
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
|
||||
fragmentTransaction.hide(usersListFragment);
|
||||
fragmentTransaction.commit();
|
||||
((MapActivity) getActivity()).searchUser(user.getFirstName());
|
||||
((MapActivity) getActivity()).updateNavigationBarState();
|
||||
});
|
||||
}
|
||||
alertDialog = alertDialogBuilderUserInput.create();
|
||||
|
||||
final AlertDialog alertDialog = alertDialogBuilderUserInput.create();
|
||||
String userNoteText = tutorTabViewModel.getNote();
|
||||
List<String> dutyHoursList = Stream.of(tutorTabViewModel.getDutyHours())
|
||||
.map(DutyHourViewModel::getSummary).toList();
|
||||
@ -277,16 +212,6 @@ public class UsersListFragment extends Fragment {
|
||||
department.setText(String.format("%s: %s", getString(R.string.userDepartment), user.getDepartment()));
|
||||
userDutyHoursTitle.setText(String.format("%s:", getString(R.string.userDutyHoursHeader)));
|
||||
|
||||
Coordinate coordinate = ((MapActivity) getActivity()).coordsMap.get(user.getId());
|
||||
if (coordinate != null){
|
||||
String label = coordinate.getLabel();
|
||||
if (!label.isEmpty()) {
|
||||
userStatusLabelLL.setVisibility(View.VISIBLE);
|
||||
userStatusLabel.setText(String.format("%s: %s", getString(R.string.user_status_label),label));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(getActivity(),
|
||||
R.layout.duty_hours_item, dutyHoursList);
|
||||
|
||||
@ -306,18 +231,39 @@ public class UsersListFragment extends Fragment {
|
||||
disposable.add(
|
||||
(fetchOnlyOnlineUsers ?
|
||||
userService.getAllActiveTutors() :
|
||||
userService.getAllTutors())
|
||||
userService.getAllOfflineTutors())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.map(this::mapUsersToSortedList)
|
||||
.map(tutors -> {
|
||||
List<User> tutorsList = new ArrayList<>(tutors);
|
||||
|
||||
List<User> onlineTutors = Stream.of(tutorsList).filter(User::isIsOnline).toList();
|
||||
|
||||
List<User> activeNotOnlineTutors = Stream.of(tutorsList)
|
||||
.filter(t -> t.isIsActive() && !onlineTutors.contains(t)).toList();
|
||||
|
||||
List<User> notActiveTutors = Stream.of(tutorsList)
|
||||
.filterNot(User::isIsActive).toList();
|
||||
|
||||
Collections.sort(onlineTutors, this::sortByUserName);
|
||||
Collections.sort(activeNotOnlineTutors, this::sortByUserName);
|
||||
Collections.sort(notActiveTutors, this::sortByUserName);
|
||||
|
||||
List<User> sortedUserList = new ArrayList<>(onlineTutors);
|
||||
sortedUserList.addAll(activeNotOnlineTutors);
|
||||
sortedUserList.addAll(notActiveTutors);
|
||||
|
||||
return sortedUserList;
|
||||
})
|
||||
.subscribeWith(new DisposableSingleObserver<List<User>>() {
|
||||
@Override
|
||||
public void onSuccess(List<User> users) {
|
||||
tutorsList.clear();
|
||||
tutorsFiltered.clear();
|
||||
tutorsList.addAll(users);
|
||||
tutorsFiltered.addAll(users);
|
||||
mAdapter.notifyDataSetChanged();
|
||||
toggleEmptyNotes();
|
||||
fetchTopCords();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -327,35 +273,17 @@ public class UsersListFragment extends Fragment {
|
||||
}));
|
||||
}
|
||||
|
||||
private List<User> mapUsersToSortedList(List<User> tutors) {
|
||||
List<User> tutorsList = new ArrayList<>(tutors);
|
||||
List<User> onlineTutors = Stream.of(tutorsList).filter(User::isIsOnline).toList();
|
||||
List<User> activeNotOnlineTutors = Stream.of(tutorsList)
|
||||
.filter(t -> t.isIsActive() && !onlineTutors.contains(t)).toList();
|
||||
List<User> notActiveTutors = Stream.of(tutorsList)
|
||||
.filterNot(User::isIsActive).toList();
|
||||
|
||||
Collections.sort(onlineTutors, this::sortByUserName);
|
||||
Collections.sort(activeNotOnlineTutors, this::sortByUserName);
|
||||
Collections.sort(notActiveTutors, this::sortByUserName);
|
||||
|
||||
List<User> sortedUserList = new ArrayList<>(onlineTutors);
|
||||
sortedUserList.addAll(activeNotOnlineTutors);
|
||||
sortedUserList.addAll(notActiveTutors);
|
||||
|
||||
return sortedUserList;
|
||||
}
|
||||
|
||||
private void searchTutorInBackend(String searchString) {
|
||||
disposable.add(
|
||||
userService.searchUser(searchString)
|
||||
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);
|
||||
tutorsFiltered.clear();
|
||||
tutorsFiltered.addAll(users);
|
||||
mAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@ -367,9 +295,8 @@ public class UsersListFragment extends Fragment {
|
||||
}
|
||||
|
||||
|
||||
public void restoreUsersList() {
|
||||
public void restoreUsersList(){
|
||||
fetchAllTutors();
|
||||
fetchTopCords();
|
||||
}
|
||||
|
||||
private int sortByUserName(User t1, User t2) {
|
||||
@ -404,58 +331,28 @@ public class UsersListFragment extends Fragment {
|
||||
createSnackbar(message);
|
||||
}
|
||||
|
||||
private void createSnackbar(String msg) {
|
||||
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();
|
||||
CoordinatorLayout.LayoutParams params=(CoordinatorLayout.LayoutParams)view.getLayoutParams();
|
||||
params.gravity = Gravity.TOP;
|
||||
view.setLayoutParams(params);
|
||||
snackbar.show();
|
||||
}
|
||||
|
||||
private void toggleEmptyNotes() {
|
||||
loader.setVisibility(View.GONE);
|
||||
noNotesView.setVisibility(View.GONE);
|
||||
|
||||
if (tutorsList.size() == 0) {
|
||||
if (tutorsList.size() > 0) {
|
||||
noNotesView.setVisibility(View.GONE);
|
||||
} else {
|
||||
noNotesView.setVisibility(View.VISIBLE);
|
||||
if (fetchOnlyOnlineUsers)
|
||||
if(fetchOnlyOnlineUsers)
|
||||
noNotesView.setText(R.string.no_online_users);
|
||||
else {
|
||||
else{
|
||||
noNotesView.setText(R.string.no_offline_users);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
private void fetchTopCords(){
|
||||
disposable.add(
|
||||
coordinateService.getTopCoordinates()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(this::addTimestamps,this::showError));
|
||||
}
|
||||
|
||||
private void addTimestamps(List<Coordinate> coordinates) {
|
||||
for (Coordinate crd :
|
||||
coordinates) {
|
||||
Long ts = crd.getTimeStamp();
|
||||
tutorsTimeStamps.put(crd.getUserId(), getDate(ts));
|
||||
}
|
||||
|
||||
mAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
private String getDate(long time) {
|
||||
Calendar cal = Calendar.getInstance(Locale.ENGLISH);
|
||||
cal.setTimeInMillis(time);
|
||||
return DateFormat.format("HH:mm dd/MM", cal).toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
@ -478,4 +375,7 @@ public class UsersListFragment extends Fragment {
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
}
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
}
|
@ -1,11 +1,8 @@
|
||||
package com.uam.wmi.findmytutor.activity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.RequiresApi;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
@ -30,7 +27,6 @@ import android.widget.Switch;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.github.ybq.android.spinkit.SpinKitView;
|
||||
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
|
||||
import com.uam.wmi.findmytutor.R;
|
||||
import com.uam.wmi.findmytutor.adapters.WhiteListAdapter;
|
||||
@ -39,33 +35,30 @@ import com.uam.wmi.findmytutor.model.StudentIdModel;
|
||||
import com.uam.wmi.findmytutor.model.User;
|
||||
import com.uam.wmi.findmytutor.network.ApiClient;
|
||||
import com.uam.wmi.findmytutor.service.UserService;
|
||||
import com.uam.wmi.findmytutor.utils.LocaleHelper;
|
||||
import com.uam.wmi.findmytutor.utils.MyDividerItemDecoration;
|
||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||
import com.uam.wmi.findmytutor.utils.RecyclerTouchListener;
|
||||
import com.uam.wmi.findmytutor.utils.RestApiHelper;
|
||||
import com.uam.wmi.findmytutor.utils.WrapContentLinearLayoutManager;
|
||||
|
||||
import java.text.Collator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.ObservableSource;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.functions.Function;
|
||||
import io.reactivex.observers.DisposableObserver;
|
||||
import io.reactivex.observers.DisposableSingleObserver;
|
||||
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)
|
||||
@ -74,43 +67,26 @@ public class WhiteList extends AppCompatActivity {
|
||||
Switch aSwitch;
|
||||
@BindView(R.id.add_to_white_list_fab)
|
||||
FloatingActionButton addToWhiteListFab;
|
||||
|
||||
@BindView(R.id.loader)
|
||||
SpinKitView loader;
|
||||
|
||||
|
||||
private CompositeDisposable disposable = new CompositeDisposable();
|
||||
private UserService userService;
|
||||
private boolean didFetched = false;
|
||||
private String tutorId;
|
||||
private WhiteListAdapter mAdapter;
|
||||
private Integer prevSize;
|
||||
private List<User> whitelistedUsers = new ArrayList<>();
|
||||
private Collator plCollator = Collator.getInstance(Locale.forLanguageTag("pl-PL"));
|
||||
private HashSet<String> whitelistedUsersIDs = new HashSet<>();
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context base) {
|
||||
super.attachBaseContext(LocaleHelper.onAttach(base));
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||
setContentView(R.layout.activity_white_list);
|
||||
ButterKnife.bind(this);
|
||||
|
||||
tutorId = PrefUtils.getUserId(getApplicationContext());
|
||||
userService = ApiClient.getClient(getApplicationContext())
|
||||
.create(UserService.class);
|
||||
|
||||
if (PrefUtils.isWhiteListing(this)) {
|
||||
aSwitch.setText(getString(R.string.action_white_list) +" "+getString(R.string.on) );
|
||||
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) +" "+getString(R.string.off) );
|
||||
}else{
|
||||
aSwitch.setText(getString(R.string.action_white_list) +" OFF");
|
||||
aSwitch.setChecked(false);
|
||||
handleChangeRequest(false);
|
||||
}
|
||||
@ -120,11 +96,11 @@ public class WhiteList extends AppCompatActivity {
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
mAdapter = new WhiteListAdapter(this, whitelistedUsers);
|
||||
recyclerView.setLayoutManager(new WrapContentLinearLayoutManager(getApplicationContext()));
|
||||
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getApplicationContext());
|
||||
recyclerView.setLayoutManager(mLayoutManager);
|
||||
recyclerView.setItemAnimator(new DefaultItemAnimator());
|
||||
recyclerView.addItemDecoration(new MyDividerItemDecoration(this, LinearLayoutManager.VERTICAL, 16));
|
||||
recyclerView.setAdapter(mAdapter);
|
||||
noNotesView.setVisibility(View.GONE);
|
||||
|
||||
/**
|
||||
* On long press on RecyclerView item, open alert dialog
|
||||
@ -143,62 +119,61 @@ public class WhiteList extends AppCompatActivity {
|
||||
}));
|
||||
|
||||
addToWhiteListFab.setOnClickListener(this::showFabDialog);
|
||||
fetchWhiteListedUsers();
|
||||
|
||||
fetchWhiteListedUsersIDs(PrefUtils.getUserId(getApplicationContext()));
|
||||
handleSwitch();
|
||||
}
|
||||
|
||||
private Observable<List<String>> getListOfWhitelistedUsers(String userId) {
|
||||
return userService.getTutorWhitelistedByID(userId)
|
||||
.toObservable()
|
||||
private void fetchWhiteListedUsersIDs(String userId) {
|
||||
disposable.add(
|
||||
userService.getTutorWhitelistedByID(userId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeWith(new DisposableSingleObserver<List<String>>() {
|
||||
@Override
|
||||
public void onSuccess(List<String> users) {
|
||||
whitelistedUsersIDs.addAll(users);
|
||||
didFetched = true;
|
||||
fetchWhiteListedUsers();
|
||||
toggleEmptyNotes();
|
||||
}
|
||||
|
||||
private Observable<User> getUserObservable(String userId) {
|
||||
return userService
|
||||
.getUserById(userId)
|
||||
.toObservable()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
showError(e);
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
private void fetchWhiteListedUsers() {
|
||||
disposable.add(getListOfWhitelistedUsers(tutorId)
|
||||
.doOnSubscribe(this::handleDoOnSubscribe)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.flatMap(Observable::fromIterable)
|
||||
.flatMap(this::getUserObservable)
|
||||
.subscribe(user -> whitelistedUsers.add(user), this::handleError,this::handleComplete));
|
||||
for (String GUID : whitelistedUsersIDs){
|
||||
disposable.add(
|
||||
userService.getUserById(GUID)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeWith(new DisposableSingleObserver<User>() {
|
||||
@Override
|
||||
public void onSuccess(User user) {
|
||||
whitelistedUsers.add(user);
|
||||
toggleEmptyNotes();
|
||||
|
||||
if (whitelistedUsers.size() == whitelistedUsersIDs.size()) {
|
||||
mAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
showError(e);
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleDoOnSubscribe(Disposable disposable) {
|
||||
prevSize = whitelistedUsers.size();
|
||||
whitelistedUsers.clear();
|
||||
didFetched = false;
|
||||
}
|
||||
|
||||
private void handleComplete() {
|
||||
Collections.sort(whitelistedUsers, this::sortByUserName);
|
||||
didFetched = true;
|
||||
refreshUI();
|
||||
}
|
||||
private void handleError(Throwable e){
|
||||
showError(e);
|
||||
didFetched = false;
|
||||
}
|
||||
|
||||
private void refreshUI() {
|
||||
toggleEmptyNotes();
|
||||
mAdapter.notifyItemRangeInserted(prevSize, whitelistedUsers.size() - prevSize);
|
||||
mAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
private int sortByUserName(User t1, User t2) {
|
||||
return plCollator.compare(t1.getLastName(), t2.getLastName());
|
||||
}
|
||||
|
||||
private void showFabDialog(View v) {
|
||||
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);
|
||||
@ -239,17 +214,18 @@ public class WhiteList extends AppCompatActivity {
|
||||
|
||||
private void sendUserToWhitelist(String body) {
|
||||
StudentIdModel studentIdModel = new StudentIdModel(body);
|
||||
|
||||
disposable.add(
|
||||
userService.addStudentToWhitelist(tutorId, studentIdModel)
|
||||
userService.addStudentToWhitelist(PrefUtils.getUserId(getApplicationContext()), studentIdModel)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(this::handleAddUser, this::showError)
|
||||
.subscribe(this::handleAddUser,this::showError)
|
||||
);
|
||||
}
|
||||
|
||||
private void handleAddUser(User user) {
|
||||
Toast.makeText(this, R.string.add_user_to_list, Snackbar.LENGTH_LONG).show();
|
||||
whitelistedUsersIDs.clear();
|
||||
whitelistedUsers.clear();
|
||||
whitelistedUsersIDs.addAll(user.getWhitelist());
|
||||
fetchWhiteListedUsers();
|
||||
}
|
||||
|
||||
@ -265,73 +241,26 @@ public class WhiteList extends AppCompatActivity {
|
||||
} else {
|
||||
message = "Network Error !";
|
||||
}
|
||||
Log.e("ERR", message);
|
||||
Toast.makeText(this, message, Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
private void toggleEmptyNotes() {
|
||||
|
||||
if (didFetched && whitelistedUsers.size() == 0) {
|
||||
noNotesView.setVisibility(View.VISIBLE);
|
||||
noNotesView.setText(R.string.list_is_empty);
|
||||
loader.setVisibility(View.GONE);
|
||||
} else if (whitelistedUsers.size() > 0) {
|
||||
noNotesView.setVisibility(View.VISIBLE);
|
||||
}else if (whitelistedUsers.size() > 0) {
|
||||
noNotesView.setVisibility(View.GONE);
|
||||
loader.setVisibility(View.GONE);
|
||||
} else {
|
||||
loader.setVisibility(View.VISIBLE);
|
||||
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)
|
||||
);
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
disposable.dispose();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -349,15 +278,58 @@ public class WhiteList extends AppCompatActivity {
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
disposable.dispose();
|
||||
}
|
||||
|
||||
@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_white_list, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@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)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -41,11 +41,11 @@ public class BlackListAdapter extends RecyclerView.Adapter<BlackListAdapter.MyVi
|
||||
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) {
|
||||
@ -73,12 +73,25 @@ public class BlackListAdapter extends RecyclerView.Adapter<BlackListAdapter.MyVi
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(()->{
|
||||
Toast.makeText(getApplicationContext(), R.string.user_removed, Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(getApplicationContext(), "User removed", Toast.LENGTH_SHORT).show();
|
||||
tutorsList.remove(position);
|
||||
notifyDataSetChanged();
|
||||
},this::showError)
|
||||
);
|
||||
});
|
||||
//
|
||||
// if (tutor.isIsOnline()) {
|
||||
// image = context.getResources().getDrawable(R.drawable.user_list_online);
|
||||
// } else {
|
||||
// image = context.getResources().getDrawable(R.drawable.user_list_offline);
|
||||
// }
|
||||
//
|
||||
// if (!tutor.isIsActive()) {
|
||||
// image = context.getResources().getDrawable(R.drawable.user_list_off);
|
||||
// }
|
||||
|
||||
// image.setBounds(0, 0, image.getIntrinsicWidth(), image.getIntrinsicHeight());
|
||||
// holder.isOnline.setCompoundDrawables(image, null, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -94,6 +107,8 @@ public class BlackListAdapter extends RecyclerView.Adapter<BlackListAdapter.MyVi
|
||||
@BindView(R.id.lastName)
|
||||
TextView lastName;
|
||||
|
||||
// @BindView(R.id.isOnline)
|
||||
// TextView isOnline;
|
||||
@BindView(R.id.removeUserImageButton)
|
||||
ImageButton imageButton;
|
||||
|
||||
@ -112,8 +127,8 @@ public class BlackListAdapter extends RecyclerView.Adapter<BlackListAdapter.MyVi
|
||||
} else {
|
||||
message = "Network Error !";
|
||||
}
|
||||
|
||||
Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show();
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,9 +1,6 @@
|
||||
package com.uam.wmi.findmytutor.adapters;
|
||||
|
||||
import android.app.DialogFragment;
|
||||
import android.app.FragmentManager;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.Editable;
|
||||
@ -14,11 +11,12 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.annimon.stream.Collectors;
|
||||
import com.annimon.stream.Stream;
|
||||
import com.uam.wmi.findmytutor.R;
|
||||
import com.uam.wmi.findmytutor.activity.TimePickerFragment;
|
||||
import com.uam.wmi.findmytutor.model.DutyHourViewModel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import butterknife.BindView;
|
||||
@ -28,12 +26,10 @@ import butterknife.ButterKnife;
|
||||
public class DutyHoursAdapter extends RecyclerView.Adapter<DutyHoursAdapter.MyViewHolder> {
|
||||
private Context context;
|
||||
private List<DutyHourViewModel> hours;
|
||||
private FragmentManager fragmentManager;
|
||||
|
||||
public DutyHoursAdapter(Context context, List<DutyHourViewModel> hours, FragmentManager fragmentManager) {
|
||||
public DutyHoursAdapter(Context context, List<DutyHourViewModel> hours) {
|
||||
this.context = context;
|
||||
this.hours = new ArrayList<DutyHourViewModel>(hours);
|
||||
this.fragmentManager = fragmentManager;
|
||||
}
|
||||
|
||||
|
||||
@ -81,7 +77,7 @@ public class DutyHoursAdapter extends RecyclerView.Adapter<DutyHoursAdapter.MyV
|
||||
}
|
||||
});
|
||||
holder.dutyStart.setText(duty.getStart());
|
||||
/* holder.dutyStart.addTextChangedListener(new TextWatcher() {
|
||||
holder.dutyStart.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
@ -96,23 +92,9 @@ public class DutyHoursAdapter extends RecyclerView.Adapter<DutyHoursAdapter.MyV
|
||||
public void afterTextChanged(Editable s) {
|
||||
duty.setStart(holder.dutyStart.getText().toString());
|
||||
}
|
||||
});*/
|
||||
holder.dutyStart.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
DialogFragment picker = new TimePickerFragment(holder.dutyStart,duty,"start");
|
||||
picker.show(fragmentManager,"time picker");
|
||||
}
|
||||
});
|
||||
holder.dutyStop.setText(duty.getEnd());
|
||||
holder.dutyStop.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
DialogFragment picker = new TimePickerFragment(holder.dutyStop,duty,"stop");
|
||||
picker.show(fragmentManager,"time picker");
|
||||
}
|
||||
});
|
||||
/* holder.dutyStop.addTextChangedListener(new TextWatcher() {
|
||||
holder.dutyStop.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
@ -127,21 +109,21 @@ public class DutyHoursAdapter extends RecyclerView.Adapter<DutyHoursAdapter.MyV
|
||||
public void afterTextChanged(Editable s) {
|
||||
duty.setEnd(holder.dutyStop.getText().toString());
|
||||
}
|
||||
});*/
|
||||
});
|
||||
holder.deleteRow.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
try{
|
||||
// Log.d("DutyIndex bf rm size",Integer.toString(getItemCount()));
|
||||
// Log.d("DutyIndex bf rm pos",Integer.toString(holder.getLayoutPosition()));
|
||||
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()));
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
/*
|
||||
package com.uam.wmi.findmytutor.adapters;
|
||||
|
||||
import android.content.Context;
|
||||
@ -10,11 +9,9 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.github.ybq.android.spinkit.SpinKitView;
|
||||
import com.uam.wmi.findmytutor.R;
|
||||
import com.uam.wmi.findmytutor.model.User;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
@ -25,12 +22,10 @@ public class TutorsListAdapter extends RecyclerView.Adapter<TutorsListAdapter.My
|
||||
|
||||
private Context context;
|
||||
private List<User> tutorsList;
|
||||
private HashMap<String, String> tutorsTimeStamps;
|
||||
|
||||
public TutorsListAdapter(Context context, List<User> tutors, HashMap<String,String> tutorsTimeStamps) {
|
||||
public TutorsListAdapter(Context context, List<User> tutors) {
|
||||
this.context = context;
|
||||
this.tutorsList = tutors;
|
||||
this.tutorsTimeStamps = tutorsTimeStamps;
|
||||
}
|
||||
@NonNull
|
||||
@Override
|
||||
@ -46,32 +41,17 @@ public class TutorsListAdapter extends RecyclerView.Adapter<TutorsListAdapter.My
|
||||
Drawable image = null;
|
||||
User tutor = tutorsList.get(position);
|
||||
|
||||
holder.firstName.setText(String.format("%s %s", tutor.getFirstName(), tutor.getLastName()));
|
||||
String ts = tutorsTimeStamps.get(tutor.getId());
|
||||
holder.firstName.setText(tutor.getFirstName());
|
||||
holder.lastName.setText(tutor.getLastName());
|
||||
|
||||
if (tutor.isIsOnline()) {
|
||||
image = context.getResources().getDrawable(R.drawable.user_list_online);
|
||||
holder.lastSeen.setText(R.string.available_now);
|
||||
holder.loader.setVisibility(View.GONE);
|
||||
} else {
|
||||
image = context.getResources().getDrawable(R.drawable.user_list_offline);
|
||||
|
||||
if (ts != null){
|
||||
holder.lastSeen.setText(R.string.last_sign);
|
||||
holder.lastSeen.append(String.format(": %s", ts));
|
||||
holder.loader.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
if (!tutor.isIsActive()) {
|
||||
image = context.getResources().getDrawable(R.drawable.user_list_off);
|
||||
if(ts != null){
|
||||
holder.lastSeen.setText(R.string.last_sign);
|
||||
holder.lastSeen.append(String.format(": %s", ts));
|
||||
}else{
|
||||
holder.lastSeen.setVisibility(View.GONE);
|
||||
}
|
||||
holder.loader.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
image.setBounds(0, 0, image.getIntrinsicWidth(), image.getIntrinsicHeight());
|
||||
@ -88,132 +68,17 @@ public class TutorsListAdapter extends RecyclerView.Adapter<TutorsListAdapter.My
|
||||
@BindView(R.id.firstName)
|
||||
TextView firstName;
|
||||
|
||||
@BindView(R.id.lastSeen)
|
||||
TextView lastSeen;
|
||||
@BindView(R.id.lastName)
|
||||
TextView lastName;
|
||||
|
||||
@BindView(R.id.isOnline)
|
||||
TextView isOnline;
|
||||
|
||||
@BindView(R.id.loader)
|
||||
SpinKitView loader;
|
||||
|
||||
MyViewHolder(View view) {
|
||||
super(view);
|
||||
ButterKnife.bind(this, view);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
package com.uam.wmi.findmytutor.adapters;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.github.ybq.android.spinkit.SpinKitView;
|
||||
import com.uam.wmi.findmytutor.R;
|
||||
import com.uam.wmi.findmytutor.model.User;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
|
||||
public class TutorsListAdapter extends RecyclerView.Adapter<TutorsListAdapter.MyViewHolder> {
|
||||
|
||||
private Context context;
|
||||
private List<User> tutorsList;
|
||||
private HashMap<String, String> tutorsTimeStamps;
|
||||
|
||||
public TutorsListAdapter(Context context, List<User> tutors, HashMap<String,String> tutorsTimeStamps) {
|
||||
this.context = context;
|
||||
this.tutorsList = tutors;
|
||||
this.tutorsTimeStamps = tutorsTimeStamps;
|
||||
}
|
||||
@NonNull
|
||||
@Override
|
||||
public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View itemView = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.tutor_list_row, parent, false);
|
||||
|
||||
return new MyViewHolder(itemView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
|
||||
Drawable image = null;
|
||||
User tutor = tutorsList.get(position);
|
||||
|
||||
holder.firstName.setText(String.format("%s %s", tutor.getFirstName(), tutor.getLastName()));
|
||||
String ts = tutorsTimeStamps.get(tutor.getId());
|
||||
|
||||
if (tutor.isIsOnline()) {
|
||||
image = context.getResources().getDrawable(R.drawable.user_list_online);
|
||||
holder.lastSeen.setText(R.string.available_now);
|
||||
holder.lastSeen.setVisibility(View.VISIBLE);
|
||||
holder.loader.setVisibility(View.GONE);
|
||||
} else if(tutor.isIsActive()){
|
||||
image = context.getResources().getDrawable(R.drawable.user_list_offline);
|
||||
|
||||
if (ts != null){
|
||||
holder.lastSeen.setText(R.string.last_sign);
|
||||
holder.lastSeen.append(String.format(": %s", ts));
|
||||
holder.loader.setVisibility(View.GONE);
|
||||
}
|
||||
} else {
|
||||
image = context.getResources().getDrawable(R.drawable.user_list_off);
|
||||
|
||||
if(ts == null){
|
||||
holder.lastSeen.setText(R.string.never_logged_in);
|
||||
}else{
|
||||
holder.lastSeen.setText(R.string.last_sign);
|
||||
holder.lastSeen.append(String.format(": %s", ts));
|
||||
}
|
||||
holder.loader.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
image.setBounds(0, 0, image.getIntrinsicWidth(), image.getIntrinsicHeight());
|
||||
holder.isOnline.setCompoundDrawables(image, null, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return tutorsList.size();
|
||||
}
|
||||
|
||||
class MyViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
@BindView(R.id.firstName)
|
||||
TextView firstName;
|
||||
|
||||
@BindView(R.id.lastSeen)
|
||||
TextView lastSeen;
|
||||
|
||||
@BindView(R.id.isOnline)
|
||||
TextView isOnline;
|
||||
|
||||
@BindView(R.id.loader)
|
||||
SpinKitView loader;
|
||||
|
||||
MyViewHolder(View view) {
|
||||
super(view);
|
||||
ButterKnife.bind(this, view);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -39,6 +39,7 @@ public class WhiteListAdapter extends RecyclerView.Adapter<WhiteListAdapter.MyVi
|
||||
private CompositeDisposable disposable = new CompositeDisposable();
|
||||
private UserService userService;
|
||||
|
||||
|
||||
public WhiteListAdapter(Context context, List<User> tutors) {
|
||||
this.context = context;
|
||||
this.tutorsList = tutors;
|
||||
@ -60,8 +61,8 @@ public class WhiteListAdapter extends RecyclerView.Adapter<WhiteListAdapter.MyVi
|
||||
User tutor = tutorsList.get(position);
|
||||
|
||||
holder.firstName.setText(tutor.getFirstName() + " " + tutor.getLastName());
|
||||
holder.lastName.setText("Index: " + tutor.getLdapLogin() + " Email: " + tutor.getEmail());
|
||||
//""
|
||||
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());
|
||||
@ -70,13 +71,25 @@ public class WhiteListAdapter extends RecyclerView.Adapter<WhiteListAdapter.MyVi
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(()->{
|
||||
Toast.makeText(getApplicationContext(), R.string.user_removed, Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(getApplicationContext(), "User removed", Toast.LENGTH_SHORT).show();
|
||||
tutorsList.remove(position);
|
||||
notifyDataSetChanged();
|
||||
},this::showError)
|
||||
);
|
||||
});
|
||||
//
|
||||
// if (tutor.isIsOnline()) {
|
||||
// image = context.getResources().getDrawable(R.drawable.user_list_online);
|
||||
// } else {
|
||||
// image = context.getResources().getDrawable(R.drawable.user_list_offline);
|
||||
// }
|
||||
//
|
||||
// if (!tutor.isIsActive()) {
|
||||
// image = context.getResources().getDrawable(R.drawable.user_list_off);
|
||||
// }
|
||||
|
||||
// image.setBounds(0, 0, image.getIntrinsicWidth(), image.getIntrinsicHeight());
|
||||
// holder.isOnline.setCompoundDrawables(image, null, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -92,6 +105,8 @@ public class WhiteListAdapter extends RecyclerView.Adapter<WhiteListAdapter.MyVi
|
||||
@BindView(R.id.lastName)
|
||||
TextView lastName;
|
||||
|
||||
// @BindView(R.id.isOnline)
|
||||
// TextView isOnline;
|
||||
@BindView(R.id.removeUserImageButton)
|
||||
ImageButton imageButton;
|
||||
|
||||
|
@ -34,11 +34,9 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.uam.wmi.findmytutor.model.Coordinate;
|
||||
import com.uam.wmi.findmytutor.network.ApiClient;
|
||||
import com.uam.wmi.findmytutor.utils.ApproximatedLocalization;
|
||||
import com.uam.wmi.findmytutor.utils.Const;
|
||||
import com.uam.wmi.findmytutor.utils.MapUtils;
|
||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||
import com.uam.wmi.findmytutor.utils.SharingLevel;
|
||||
import com.uam.wmi.findmytutor.utils.WifiUtils;
|
||||
|
||||
import org.apache.commons.collections4.queue.CircularFifoQueue;
|
||||
|
||||
@ -64,7 +62,7 @@ public class BackgroundLocalizationService extends Service {
|
||||
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 static int coordinatesHistoryLength = 5;
|
||||
private Boolean highAccuracyMode;
|
||||
private Location mLastLocation;
|
||||
private Boolean stopService = false;
|
||||
@ -124,12 +122,6 @@ public class BackgroundLocalizationService extends Service {
|
||||
mCurrentLocation = locationResult.getLastLocation();
|
||||
sendCoordinateToBackend(mCurrentLocation);
|
||||
changeBackgroundMode();
|
||||
|
||||
//Restart service when a user started using presence in GPS mode and wmi is currently available
|
||||
if (WifiUtils.checkIfUserIsInRangeOfWmiWifi(getApplicationContext())
|
||||
&& PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.PRESENCE.toString())) {
|
||||
restartService();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -148,60 +140,22 @@ public class BackgroundLocalizationService extends Service {
|
||||
startForeground(1001, notification);
|
||||
}
|
||||
|
||||
if (!stopService) {
|
||||
if (PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.PRESENCE.toString())) {
|
||||
if (WifiUtils.checkIfUserIsInRangeOfWmiWifi(getApplicationContext())) {
|
||||
Location presenceFakeLoc = new Location("");
|
||||
|
||||
presenceFakeLoc.setLatitude(Const.presenceLatitude);
|
||||
presenceFakeLoc.setLongitude(Const.presenceLongitude);
|
||||
presenceFakeLoc.setAltitude(0);
|
||||
createPresenceLooper(presenceFakeLoc);
|
||||
} else {
|
||||
createFusedLocationClient();
|
||||
if (!stopService && !PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.MANUAL.toString())) {
|
||||
createFusedLocationClient();
|
||||
} else if (!stopService &&
|
||||
PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.MANUAL.toString())) {
|
||||
mStatusChecker = () -> {
|
||||
try {
|
||||
sendCoordinateToBackend(fakeLoc);
|
||||
} finally {
|
||||
mHandler.postDelayed(mStatusChecker, notify_interval);
|
||||
}
|
||||
} else if (PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.EXACT.toString())
|
||||
|| PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.APPROXIMATED.toString())
|
||||
) {
|
||||
createFusedLocationClient();
|
||||
} else if (PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.MANUAL.toString())) {
|
||||
Location manualFakeLoc = new Location("");
|
||||
};
|
||||
|
||||
manualFakeLoc.setLatitude(0);
|
||||
manualFakeLoc.setLongitude(0);
|
||||
manualFakeLoc.setAltitude(0);
|
||||
createLowBatteryLooper(manualFakeLoc);
|
||||
}
|
||||
AsyncTask.execute(mStatusChecker);
|
||||
}
|
||||
}
|
||||
|
||||
private void createLowBatteryLooper(Location fakeLoc) {
|
||||
mStatusChecker = () -> {
|
||||
try {
|
||||
sendCoordinateToBackend(fakeLoc);
|
||||
} finally {
|
||||
mHandler.postDelayed(mStatusChecker, notify_interval);
|
||||
}
|
||||
};
|
||||
AsyncTask.execute(mStatusChecker);
|
||||
}
|
||||
|
||||
private void createPresenceLooper(Location fakeLoc) {
|
||||
mStatusChecker = () -> {
|
||||
try {
|
||||
if (WifiUtils.checkIfUserIsInRangeOfWmiWifi(getApplicationContext())) {
|
||||
sendCoordinateToBackend(fakeLoc);
|
||||
} else {
|
||||
restartService();
|
||||
}
|
||||
} finally {
|
||||
mHandler.postDelayed(mStatusChecker, notify_interval);
|
||||
}
|
||||
};
|
||||
AsyncTask.execute(mStatusChecker);
|
||||
}
|
||||
|
||||
|
||||
private void createFusedLocationClient() {
|
||||
Integer saveMode = Long.valueOf(notify_interval).compareTo(Long.valueOf(offlineBackgroundLocationInterval));
|
||||
|
||||
@ -214,7 +168,7 @@ public class BackgroundLocalizationService extends Service {
|
||||
if (saveMode != 0) {
|
||||
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
|
||||
} else {
|
||||
mLocationRequest.setPriority(LocationRequest.PRIORITY_LOW_POWER);
|
||||
mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
|
||||
}
|
||||
|
||||
mLocationRequest.setFastestInterval(notify_interval);
|
||||
@ -232,24 +186,24 @@ public class BackgroundLocalizationService extends Service {
|
||||
private void changeBackgroundMode() {
|
||||
Integer prevInterval = notify_interval;
|
||||
Boolean shouldExtendTimeInterval = Stream.of(coordinatesHistory)
|
||||
.map(MapUtils::checkIfCoordinateIsValid).takeWhile(s -> !s).toList().size() == coordinatesHistoryLength;
|
||||
.map(MapUtils::checkIfCoordinateIsValid).takeWhile(s -> !s).toList().size() == coordinatesHistory.size();
|
||||
|
||||
Boolean shouldAbbreviateTimeInterval = Stream.of(coordinatesHistory).
|
||||
map(MapUtils::checkIfCoordinateIsValid).filter(x -> x).toList().size() > 0;
|
||||
|
||||
if (shouldExtendTimeInterval) {
|
||||
notify_interval = notify_interval_outside_building;
|
||||
}
|
||||
|
||||
if (shouldAbbreviateTimeInterval) {
|
||||
notify_interval = notify_interval_inside_building;
|
||||
}
|
||||
|
||||
if (coordinatesHistory.size() > 4 && shouldExtendTimeInterval) {
|
||||
notify_interval = notify_interval_outside_building;
|
||||
}
|
||||
|
||||
Integer changedMode = Long.valueOf(prevInterval).compareTo(Long.valueOf(notify_interval));
|
||||
if (changedMode != 0) {
|
||||
updateListeners();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
@ -340,7 +294,6 @@ public class BackgroundLocalizationService extends Service {
|
||||
latitude = location.getLatitude();
|
||||
longitude = location.getLongitude();
|
||||
altitude = location.getAltitude();
|
||||
Log.e(TAG, "TASK" + latitude + " " + longitude);
|
||||
approximatedLocalization = new ApproximatedLocalization(MapUtils.loadJsonFromAsset(getApplicationContext(), "building.geojson"));
|
||||
approximatedBuildingPart = approximatedLocalization.getNameOfBuildingPart(Point.fromLngLat(longitude, latitude));
|
||||
}
|
||||
@ -353,7 +306,6 @@ public class BackgroundLocalizationService extends Service {
|
||||
|
||||
if (locationLevel.equals(SharingLevel.PRESENCE.toString())) {
|
||||
if (!MapUtils.checkIfCoordinateIsValid(latitude, longitude)) {
|
||||
coordinatesHistory.add(fakeLoc);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ public interface CoordinateService {
|
||||
Single<List<Coordinate>> getCoordinatesByUserId(@Path("userId") String userId);
|
||||
|
||||
@GET("api/coordinates/userTop/{userId}")
|
||||
Single <Coordinate> getTopCoordinateByUserId(@Path("userId") String userId);
|
||||
Single<List<Coordinate>> getTopCoordinatesByUserId(@Path("userId") String userId);
|
||||
|
||||
@GET("api/coordinates/top")
|
||||
Single<List<Coordinate>> getTopCoordinates();
|
||||
@ -42,6 +42,4 @@ public interface CoordinateService {
|
||||
@DELETE("api/coordinates/{id}")
|
||||
Completable deleteCoordinatesById(@Path("id") String id);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,24 +0,0 @@
|
||||
package com.uam.wmi.findmytutor.service;
|
||||
|
||||
import com.uam.wmi.findmytutor.model.PredefinedCoordViewModel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.Single;
|
||||
import retrofit2.http.Body;
|
||||
import retrofit2.http.DELETE;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.HTTP;
|
||||
import retrofit2.http.POST;
|
||||
import retrofit2.http.Path;
|
||||
|
||||
public interface PredefinedCoordinatesService {
|
||||
@GET("api/users/predefined/coordinate/{tutorId}")
|
||||
Single<List<PredefinedCoordViewModel>> getUserPredefinedCoords(@Path("tutorId") String tutorId);
|
||||
|
||||
@POST("api/users/predefined/coordinate/{tutorId}")
|
||||
Single <PredefinedCoordViewModel> postUserPredefinedCoord(@Path("tutorId") String tutorId, @Body PredefinedCoordViewModel coord);
|
||||
|
||||
@HTTP(method = "DELETE", path = "api/users/predefined/coordinate/{tutorId}", hasBody = true)
|
||||
Single<List<PredefinedCoordViewModel>> deleteUserPredefinedCoord(@Path("tutorId") String tutorId, @Body String uuid);
|
||||
}
|
@ -5,27 +5,25 @@ import io.reactivex.Single;
|
||||
import retrofit2.http.Body;
|
||||
import retrofit2.http.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}")
|
||||
@HTTP(method = "DELETE", path = "api/users/predefined/status/{tutorId}", hasBody = true)
|
||||
@DELETE("api/users/predefined/status/{tutorId}")
|
||||
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);
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ 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;
|
||||
@ -39,9 +38,6 @@ public interface UserService {
|
||||
@GET("api/users/tutors/active")
|
||||
Single <List<User>> getAllActiveTutors();
|
||||
|
||||
|
||||
|
||||
|
||||
@GET("api/users/tutors/offline")
|
||||
Single <List<User>> getAllOfflineTutors();
|
||||
|
||||
@ -63,9 +59,6 @@ public interface UserService {
|
||||
@GET("api/users/{id}")
|
||||
Single <User> getUserById(@Path("id") String userID);
|
||||
|
||||
@GET("api/users/self/{id}")
|
||||
Single <User> getSelf(@Path("id") String userID);
|
||||
|
||||
@PUT("api/users/{id}")
|
||||
Completable updateUserByID(@Path("id") String userID, @Body User user);
|
||||
|
||||
@ -82,7 +75,7 @@ public interface UserService {
|
||||
Completable setUserInActive(@Path("userID") String userID);
|
||||
|
||||
@GET("api/users/blacklist/{tutorID}")
|
||||
Single <List<String>> 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);
|
||||
|
@ -7,7 +7,6 @@ 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 = 360000;
|
||||
public final static Integer defaultMapZoom = 17;
|
||||
@ -17,10 +16,8 @@ public class Const {
|
||||
public final static String presenceApproximatedName = "Unknown";
|
||||
public final static Range<Double> buildingLatitudeRange = Range.create(52.466092, 52.467529);
|
||||
public final static Range<Double> buildingLongitudeRange = Range.create(16.926159, 16.927759);
|
||||
public final static Range<Double> outsideLatitudeRange = Range.create(52.4651, 52.468837);
|
||||
public final static Range<Double> outsideLongitudeRange = Range.create(16.9186, 16.936004);
|
||||
public final static Range<Double> outsideLatitudeRange = Range.create(52.463512, 52.468837);
|
||||
public final static Range<Double> outsideLongitudeRange = Range.create(16.922372, 16.936004);
|
||||
public final static List<String> validApproximatedLocations = Arrays.asList("Skrzydło B", "Skrzydło A", "Aule", "Łącznik", "Biblioteka", "Hol", "Unknown");
|
||||
public final static String WMI_SSID_NAME = "wmi";
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,80 +0,0 @@
|
||||
package com.uam.wmi.findmytutor.utils;
|
||||
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Build;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class LocaleHelper {
|
||||
|
||||
private static final String SELECTED_LANGUAGE = "Locale.Helper.Selected.Language";
|
||||
|
||||
public static Context onAttach(Context context) {
|
||||
String lang = getPersistedData(context, Locale.getDefault().getLanguage());
|
||||
return setLocale(context, lang);
|
||||
}
|
||||
|
||||
public static Context onAttach(Context context, String defaultLanguage) {
|
||||
String lang = getPersistedData(context, defaultLanguage);
|
||||
return setLocale(context, lang);
|
||||
}
|
||||
|
||||
public static String getLanguage(Context context) {
|
||||
return getPersistedData(context, Locale.getDefault().getLanguage());
|
||||
}
|
||||
|
||||
public static Context setLocale(Context context, String language) {
|
||||
persist(context, language);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
return updateResources(context, language);
|
||||
}
|
||||
|
||||
return updateResourcesLegacy(context, language);
|
||||
}
|
||||
|
||||
private static String getPersistedData(Context context, String defaultLanguage) {
|
||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
return preferences.getString(SELECTED_LANGUAGE, defaultLanguage);
|
||||
}
|
||||
|
||||
private static void persist(Context context, String language) {
|
||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
|
||||
editor.putString(SELECTED_LANGUAGE, language);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.N)
|
||||
private static Context updateResources(Context context, String language) {
|
||||
Locale locale = new Locale(language);
|
||||
Locale.setDefault(locale);
|
||||
|
||||
Configuration configuration = context.getResources().getConfiguration();
|
||||
configuration.setLocale(locale);
|
||||
|
||||
return context.createConfigurationContext(configuration);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private static Context updateResourcesLegacy(Context context, String language) {
|
||||
Locale locale = new Locale(language);
|
||||
Locale.setDefault(locale);
|
||||
|
||||
Resources resources = context.getResources();
|
||||
|
||||
Configuration configuration = resources.getConfiguration();
|
||||
configuration.locale = locale;
|
||||
|
||||
resources.updateConfiguration(configuration, resources.getDisplayMetrics());
|
||||
|
||||
return context;
|
||||
}
|
||||
}
|
@ -1,32 +1,10 @@
|
||||
package com.uam.wmi.findmytutor.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Build;
|
||||
import android.support.v4.os.ConfigurationCompat;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class LocaleUtils {
|
||||
public static String getCurrentLocale() {
|
||||
return String.valueOf(ConfigurationCompat.getLocales(Resources.getSystem().getConfiguration()));
|
||||
}
|
||||
|
||||
private static Context updateResources(Context context, String language) {
|
||||
Locale locale = new Locale(language);
|
||||
Locale.setDefault(locale);
|
||||
|
||||
Resources res = context.getResources();
|
||||
Configuration config = new Configuration(res.getConfiguration());
|
||||
if (Build.VERSION.SDK_INT >= 22) {
|
||||
config.setLocale(locale);
|
||||
context = context.createConfigurationContext(config);
|
||||
} else {
|
||||
config.locale = locale;
|
||||
res.updateConfiguration(config, res.getDisplayMetrics());
|
||||
}
|
||||
return context;
|
||||
public static String getCurrentLocale(){
|
||||
return String.valueOf(ConfigurationCompat.getLocales(Resources.getSystem().getConfiguration()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,8 @@
|
||||
package com.uam.wmi.findmytutor.utils;
|
||||
|
||||
import android.animation.TypeEvaluator;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.location.Location;
|
||||
import android.net.Uri;
|
||||
import android.provider.Settings;
|
||||
|
||||
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
||||
@ -14,15 +10,12 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.uam.wmi.findmytutor.R;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext;
|
||||
import static com.uam.wmi.findmytutor.utils.Const.outsideLatitudeRange;
|
||||
import static com.uam.wmi.findmytutor.utils.Const.outsideLongitudeRange;
|
||||
import static com.uam.wmi.findmytutor.utils.PrefUtils.shouldBatteryExclusionBeShown;
|
||||
import static com.uam.wmi.findmytutor.utils.Const.outsideLatitudeRange;
|
||||
|
||||
public class MapUtils {
|
||||
|
||||
@ -48,8 +41,8 @@ public class MapUtils {
|
||||
|
||||
// Map Bounds Area
|
||||
public static void setZoom(MapboxMap mapboxMap, Integer zoom) {
|
||||
makeNewCamera(mapboxMap, 52.466799, 16.927002, zoom, 0, 0, 1000);
|
||||
mapboxMap.setMinZoomPreference(16); // TODO export to map config
|
||||
makeNewCamera(mapboxMap, 52.466799, 16.927002, zoom, 0, 0, 1000);
|
||||
mapboxMap.setMinZoomPreference(16); // TODO export to map config
|
||||
}
|
||||
|
||||
public static void makeNewCamera(MapboxMap mapboxMap, double lat, double lon, int zoomParam, int bearingParam, int tiltParam, int duration) {
|
||||
@ -80,34 +73,14 @@ public class MapUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static Boolean checkIfCoordinateIsValid(Location coordinate) {
|
||||
return outsideLatitudeRange.contains(coordinate.getLatitude()) && outsideLongitudeRange.contains(coordinate.getLongitude());
|
||||
public static Boolean checkIfCoordinateIsValid(Location coordinate){
|
||||
return outsideLatitudeRange.contains(coordinate.getLatitude()) && outsideLongitudeRange.contains(coordinate.getLongitude());
|
||||
}
|
||||
|
||||
public static Boolean checkIfCoordinateIsValid(Double latitude, Double longitude) {
|
||||
public static Boolean checkIfCoordinateIsValid(Double latitude, Double longitude){
|
||||
return Const.buildingLatitudeRange.contains(latitude) && Const.buildingLongitudeRange.contains(longitude);
|
||||
}
|
||||
|
||||
public static void BatteryOptimizationsExceptionCheck(Context context) {
|
||||
if (shouldBatteryExclusionBeShown(getApplicationContext())) {
|
||||
PrefUtils.setBatteryExlusionInfoStatus(getApplicationContext(), false);
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
builder.setTitle(R.string.batter_exclusions_title);
|
||||
builder.setMessage(R.string.batter_exclusions_message)
|
||||
.setPositiveButton(R.string.ok, (dialog, id) -> {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
||||
Uri uri = Uri.fromParts("package", getApplicationContext().getPackageName(), null);
|
||||
intent.setData(uri);
|
||||
context.startActivity(intent);
|
||||
})
|
||||
.setNegativeButton(R.string.cancel, (dialog, id) -> {
|
||||
|
||||
}).show();
|
||||
}
|
||||
}
|
||||
|
||||
// Function for marker animation
|
||||
public static class LatLngEvaluator implements TypeEvaluator<LatLng> {
|
||||
// Method is used to interpolate the marker animation.
|
||||
|
@ -60,16 +60,6 @@ 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");
|
||||
@ -104,11 +94,6 @@ 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();
|
||||
@ -243,13 +228,4 @@ public class PrefUtils {
|
||||
return getSharedPreferences(context).getBoolean("whitelisting", false);
|
||||
}
|
||||
|
||||
public static Boolean shouldBatteryExclusionBeShown(Context context) {
|
||||
return getSharedPreferences(context).getBoolean("show_battery_exclusion", false);
|
||||
}
|
||||
|
||||
public static void setBatteryExlusionInfoStatus(Context context, Boolean flag) {
|
||||
SharedPreferences.Editor editor = getSharedPreferences(context).edit();
|
||||
editor.putBoolean("show_battery_exclusion", flag);
|
||||
editor.apply();
|
||||
}
|
||||
}
|
@ -2,8 +2,6 @@ package com.uam.wmi.findmytutor.utils;
|
||||
import android.content.Context;
|
||||
import android.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;
|
||||
@ -11,63 +9,31 @@ 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);
|
||||
init(context, attrs);
|
||||
}
|
||||
|
||||
private void init(Context context, AttributeSet attrs){
|
||||
for (int i=0;i<attrs.getAttributeCount();i++) {
|
||||
String attr = attrs.getAttributeName(i);
|
||||
try {
|
||||
if(attr.equalsIgnoreCase("key")){
|
||||
Log.e("BUTTON_ERR",attr);
|
||||
String val = attrs.getAttributeValue(i);
|
||||
|
||||
switch (val) {
|
||||
case "remove_manual_status":
|
||||
buttonText = context.getResources().getString(R.string.preference_manual_location_button_remove);
|
||||
break;
|
||||
case "manual_location_button":
|
||||
buttonText = context.getResources().getString(R.string.preference_manual_location_button);
|
||||
break;
|
||||
case "remove_manual_location":
|
||||
buttonText = context.getResources().getString(R.string.preference_manual_location_button_remove);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
buttonText = "";
|
||||
Log.e("BUTTON_ERR", String.valueOf(e));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setText(String text){
|
||||
prefButton.setText(text);
|
||||
}
|
||||
@Override
|
||||
protected View onCreateView(ViewGroup parent) {
|
||||
return super.onCreateView(parent);
|
||||
View view = super.onCreateView(parent);
|
||||
// LayoutInflater li = (LayoutInflater)getContext().getSystemService( Context.LAYOUT_INFLATER_SERVICE );
|
||||
// View temp =li.inflate( R.layout.preference_button_widget, parent, false);
|
||||
return view;
|
||||
}
|
||||
@Override
|
||||
protected void onBindView(View view)
|
||||
{
|
||||
super.onBindView(view);
|
||||
prefButton = view.findViewById(R.id.button_choose_from_map);
|
||||
prefButton.setText(buttonText);
|
||||
if(prefButton != null)
|
||||
Button button = (Button)view.findViewById(R.id.button_choose_from_map);
|
||||
if(button != null)
|
||||
{
|
||||
prefButton.setOnClickListener(view1 -> {
|
||||
callChangeListener(null);
|
||||
notifyChanged();
|
||||
});
|
||||
button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
callChangeListener(null);
|
||||
notifyChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,13 +1,16 @@
|
||||
package com.uam.wmi.findmytutor.utils;
|
||||
|
||||
|
||||
import android.support.v7.widget.SearchView;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.subjects.PublishSubject;
|
||||
|
||||
|
||||
public class RxSearchObservable {
|
||||
|
||||
private RxSearchObservable() {
|
||||
// no instance
|
||||
}
|
||||
|
||||
public static Observable<String> fromView(SearchView searchView) {
|
||||
@ -27,8 +30,13 @@ public class RxSearchObservable {
|
||||
subject.onNext(text);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
return subject;
|
||||
}
|
||||
}
|
||||
|
@ -1,30 +0,0 @@
|
||||
package com.uam.wmi.findmytutor.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.wifi.WifiInfo;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class WifiUtils {
|
||||
|
||||
public static String getWifiName(Context context) {
|
||||
WifiManager manager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
|
||||
if (Objects.requireNonNull(manager).isWifiEnabled()) {
|
||||
WifiInfo wifiInfo = manager.getConnectionInfo();
|
||||
if (wifiInfo != null) {
|
||||
NetworkInfo.DetailedState state = WifiInfo.getDetailedStateOf(wifiInfo.getSupplicantState());
|
||||
if (state == NetworkInfo.DetailedState.CONNECTED || state == NetworkInfo.DetailedState.OBTAINING_IPADDR) {
|
||||
return wifiInfo.getSSID();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Boolean checkIfUserIsInRangeOfWmiWifi(Context context) {
|
||||
return Objects.equals(getWifiName(context), Const.WMI_SSID_NAME);
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package com.uam.wmi.findmytutor.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
|
||||
public class WrapContentLinearLayoutManager extends LinearLayoutManager {
|
||||
public WrapContentLinearLayoutManager(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {
|
||||
try {
|
||||
super.onLayoutChildren(recycler, state);
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
|
||||
<path
|
||||
android:pathData="M0 0h24v24H0z" />
|
||||
<path
|
||||
android:fillColor="#FFFF"
|
||||
android:pathData="M2 12C2 6.48 6.48 2 12 2s10 4.48 10 10-4.48 10-10 10S2 17.52 2 12zm10 6c3.31 0 6-2.69 6-6s-2.69-6-6-6-6 2.69-6 6 2.69 6 6 6z" />
|
||||
<path
|
||||
android:pathData="M0 0h24v24H0z" />
|
||||
</vector>
|
@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
|
||||
<path
|
||||
android:fillColor="#ffffff"
|
||||
android:pathData="M22 10l-6-6H4c-1.1 0-2 0.9-2 2v12.01c0 1.1 0.9 1.99 2 1.99l16-0.01c1.1 0 2-0.89 2-1.99v-8zm-7-4.5l5.5 5.5H15V5.5z" />
|
||||
<path
|
||||
android:pathData="M0 0h24v24H0V0z" />
|
||||
</vector>
|
@ -40,7 +40,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:text="@string/block_the_users"
|
||||
android:text="Block the users"
|
||||
android:textSize="15sp"/>
|
||||
|
||||
<Switch
|
||||
|
@ -4,13 +4,13 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fontFamily="@font/lato_regular"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
android:fontFamily="@font/lato_regular"
|
||||
tools:context=".activity.LoginActivity">
|
||||
|
||||
|
||||
@ -58,7 +58,6 @@
|
||||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:layout_width="match_parent"
|
||||
app:passwordToggleEnabled="true"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<EditText
|
||||
@ -75,6 +74,7 @@
|
||||
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
|
||||
|
||||
<Button
|
||||
android:id="@+id/email_sign_in_button"
|
||||
style="?android:textAppearanceSmall"
|
||||
@ -84,6 +84,7 @@
|
||||
android:text="@string/action_log_in"
|
||||
android:textStyle="bold" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
</LinearLayout>
|
@ -5,29 +5,30 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fontFamily="@font/lato_regular"
|
||||
android:id="@+id/activity_tutor_tab"
|
||||
tools:context=".activity.TutorTab">
|
||||
|
||||
<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:layout_height="wrap_content"
|
||||
android:theme="@style/AppTheme.AppBarOverlay">
|
||||
|
||||
<android.support.design.widget.CollapsingToolbarLayout
|
||||
android:id="@+id/toolbar_layout"
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
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"
|
||||
/>
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="?attr/colorPrimary"
|
||||
app:popupTheme="@style/AppTheme.PopupOverlay" />
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<include layout="@layout/content_tutor_tab" />
|
||||
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/fab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_margin="@dimen/fab_margin"
|
||||
app:srcCompat="@android:drawable/ic_dialog_email" />
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
@ -40,7 +40,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:text="@string/be_visible_for_these_users"
|
||||
android:text="Be visible for these users"
|
||||
android:textSize="15sp"/>
|
||||
|
||||
<Switch
|
||||
|
@ -28,21 +28,6 @@
|
||||
android:textColor="@color/msg_no_notes"
|
||||
android:textSize="@dimen/msg_no_notes" />
|
||||
|
||||
<com.github.ybq.android.spinkit.SpinKitView
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/loader"
|
||||
style="@style/SpinKitView.Large.Wave"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="150dp"
|
||||
app:SpinKit_Color="@color/msg_no_notes"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="@dimen/margin_top_no_notes"
|
||||
android:fontFamily="sans-serif-light"
|
||||
android:text="@string/loading"
|
||||
android:textColor="@color/msg_no_notes"
|
||||
android:textSize="@dimen/msg_no_notes" />
|
||||
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
@ -1,61 +1,188 @@
|
||||
<?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"
|
||||
|
||||
|
||||
<ScrollView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:mapbox="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
|
||||
|
||||
<LinearLayout
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
android:id="@+id/activity_tutor_content"
|
||||
tools:context=".activity.TutorTab">
|
||||
android:orientation="vertical"
|
||||
android:fontFamily="@font/lato_regular"
|
||||
android:paddingLeft="@dimen/activity_margin"
|
||||
android:paddingRight="@dimen/activity_margin"
|
||||
android:paddingTop="@dimen/activity_margin">
|
||||
<LinearLayout android:layout_width="fill_parent"
|
||||
android:id="@+id/linearLayout1" android:layout_height="wrap_content">
|
||||
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:id="@+id/app_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="132dp"
|
||||
android:fitsSystemWindows="true"
|
||||
android:theme="@style/AppTheme.AppBarOverlay">
|
||||
|
||||
<android.support.design.widget.CollapsingToolbarLayout
|
||||
android:id="@+id/toolbar_layout"
|
||||
<Button
|
||||
android:id="@+id/scrapTutorTab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1.0"
|
||||
android:text="@string/scrap_tutor_tab" />
|
||||
<ImageButton
|
||||
android:id="@+id/contentTutorTabInfoImageButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
mapbox:srcCompat="@drawable/outline_info_24"/>
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:id="@+id/userName"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/dimen_10"
|
||||
android:fontFamily="sans-serif-medium"
|
||||
android:lineSpacingExtra="8sp"
|
||||
android:textColor="@color/mapboxRedDark"
|
||||
android:textSize="@dimen/lbl_new_note_title"
|
||||
android:textStyle="normal" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
app:contentScrim="?attr/colorPrimary"
|
||||
app:expandedTitleGravity="top|right"
|
||||
app:layout_scrollFlags="scroll|exitUntilCollapsed"
|
||||
app:toolbarId="@+id/toolbar">
|
||||
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
>
|
||||
<TextView
|
||||
android:id="@+id/personalInfoTitle"
|
||||
android:textSize="16sp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="0dp"
|
||||
android:paddingBottom="0dp"
|
||||
android:textColor="@color/mapboxRedDark"
|
||||
android:text="@string/personalInfoTitle"/>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:gravity="left|bottom"
|
||||
android:orientation="vertical"
|
||||
android:padding="10dp"
|
||||
app:layout_collapseMode="parallax">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/userName"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
>
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:text="User Name"
|
||||
android:textSize="22sp" />
|
||||
android:layout_weight="0.7">
|
||||
|
||||
<android.support.design.widget.TextInputEditText
|
||||
android:id="@+id/userDepartment"
|
||||
android:maxLines="1"
|
||||
android:inputType="text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/hint_department"
|
||||
android:lineSpacingExtra="8sp"
|
||||
android:paddingTop="5dp"
|
||||
android:textColor="@color/note_list_text" />
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.3">
|
||||
|
||||
<android.support.design.widget.TextInputEditText
|
||||
android:id="@+id/userRoom"
|
||||
android:maxLines="1"
|
||||
android:inputType="text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/hint_room"
|
||||
android:lineSpacingExtra="8sp"
|
||||
android:paddingTop="5dp"
|
||||
android:textColor="@color/note_list_text" />
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
app:layout_collapseMode="pin"
|
||||
app:popupTheme="@style/AppTheme.PopupOverlay" />
|
||||
android:layout_height="wrap_content">
|
||||
<android.support.design.widget.TextInputEditText
|
||||
android:id="@+id/userEmail"
|
||||
android:maxLines="1"
|
||||
android:inputType="text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:lineSpacingExtra="8sp"
|
||||
android:paddingTop="5dp"
|
||||
android:textColor="@color/note_list_text"
|
||||
android:hint="@string/hint_email"
|
||||
/>
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</android.support.design.widget.CollapsingToolbarLayout>
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
<TextView
|
||||
android:id="@+id/dutyTitle"
|
||||
android:textSize="16sp"
|
||||
|
||||
<include layout="@layout/content_tutor_tab_layout" />
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="0dp"
|
||||
android:paddingBottom="0dp"
|
||||
android:textColor="@color/mapboxRedDark"
|
||||
android:text="@string/dutyTitle"/>
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/dutyHourView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="100dp"
|
||||
android:scrollbars="vertical" />
|
||||
|
||||
<LinearLayout android:layout_width="fill_parent"
|
||||
android:id="@+id/linearLayout1" android:layout_height="wrap_content">
|
||||
|
||||
|
||||
<Button
|
||||
android:id="@+id/addDuty"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_weight="1.0"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:layout_gravity="end"
|
||||
android:text="@string/addDuty" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:textSize="16sp"
|
||||
android:id="@+id/userNoteTitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="0dp"
|
||||
android:paddingBottom="0dp"
|
||||
android:textColor="@color/mapboxRedDark"
|
||||
android:text="@string/userNoteTitle"/>
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<android.support.design.widget.TextInputEditText
|
||||
|
||||
android:id="@+id/userNote"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="150dp"
|
||||
android:lineSpacingExtra="8sp"
|
||||
android:paddingTop="5dp"
|
||||
android:textColor="@color/note_list_text"
|
||||
android:hint="@string/tutorTabHint"
|
||||
android:inputType="textMultiLine"
|
||||
android:maxLength="1000"
|
||||
android:maxLines="7"
|
||||
android:requiresFadingEdge="vertical"
|
||||
android:scrollbars="vertical"/>
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
|
||||
|
||||
<Button
|
||||
android:id="@+id/saveButon"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/saveButton" />
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
@ -1,215 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fillViewport="true"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
tools:context=".activity.TutorTab"
|
||||
android:fontFamily="@font/lato_regular"
|
||||
tools:showIn="@layout/content_tutor_tab">
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fontFamily="@font/lato_regular"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
tools:context=".activity.TutorTab">
|
||||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:id="@+id/userDepartmentLayout"
|
||||
android:layout_width="189dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/userEmailLayout"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginStart="25dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginEnd="30dp"
|
||||
android:layout_toEndOf="@+id/userRoomLayout">
|
||||
|
||||
<android.support.design.widget.TextInputEditText
|
||||
android:id="@+id/userDepartment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/userDepartmentLayout"
|
||||
android:layout_alignStart="@+id/userDepartmentLayout"
|
||||
android:layout_alignTop="@+id/userDepartmentLayout"
|
||||
android:hint="@string/hint_department"
|
||||
android:inputType="text"
|
||||
android:lineSpacingExtra="8sp"
|
||||
android:maxLines="1"
|
||||
android:paddingTop="5dp"
|
||||
android:textColor="@color/note_list_text" />
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:id="@+id/userRoomLayout"
|
||||
android:layout_width="115dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/userEmailLayout"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_marginStart="30dp"
|
||||
android:layout_marginTop="10dp">
|
||||
|
||||
<android.support.design.widget.TextInputEditText
|
||||
android:id="@+id/userRoom"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
||||
android:layout_below="@+id/userRoomLayout"
|
||||
android:layout_alignTop="@+id/userRoomLayout"
|
||||
android:hint="@string/hint_room"
|
||||
android:inputType="text"
|
||||
android:lineSpacingExtra="8sp"
|
||||
android:maxLines="1"
|
||||
android:paddingTop="5dp"
|
||||
android:textColor="@color/note_list_text" />
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/personalInfoTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignStart="@+id/userRoomLayout"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginTop="30dp"
|
||||
android:layout_marginStart="5dp"
|
||||
android:text="@string/personalInfoTitle"
|
||||
android:textColor="@color/mapboxRedDark"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:id="@+id/userEmailLayout"
|
||||
android:layout_width="326dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginStart="30dp"
|
||||
android:layout_marginTop="70dp"
|
||||
android:layout_marginEnd="30dp">
|
||||
|
||||
<android.support.design.widget.TextInputEditText
|
||||
android:id="@+id/userEmail"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignStart="@+id/userEmailLayout"
|
||||
android:layout_alignTop="@+id/userEmailLayout"
|
||||
android:hint="@string/hint_email"
|
||||
android:inputType="textEmailAddress"
|
||||
android:lineSpacingExtra="8sp"
|
||||
android:maxLines="1"
|
||||
android:paddingTop="5dp"
|
||||
android:textColor="@color/note_list_text" />
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/dutyTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/userRoomLayout"
|
||||
android:layout_alignStart="@+id/userRoomLayout"
|
||||
android:layout_marginStart="5dp"
|
||||
android:layout_marginEnd="30dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:gravity="center"
|
||||
android:text="@string/dutyTitle"
|
||||
android:textColor="@color/mapboxRedDark"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/dutyHourView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="120dp"
|
||||
android:layout_below="@+id/addDuty"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_marginStart="30dp"
|
||||
android:layout_marginTop="15dp"
|
||||
android:layout_marginEnd="50dp"
|
||||
android:scrollbars="vertical" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/userNoteTitle"
|
||||
android:textStyle="bold"
|
||||
android:layout_marginStart="5dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/dutyHourView"
|
||||
android:layout_alignStart="@+id/userRoomLayout"
|
||||
android:text="@string/userNoteTitle"
|
||||
android:textColor="@color/mapboxRedDark"
|
||||
android:textSize="18sp" />
|
||||
|
||||
<android.support.v7.widget.AppCompatButton
|
||||
android:id="@+id/addDuty"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/white"
|
||||
app:backgroundTint="@color/colorPrimary"
|
||||
android:layout_alignBaseline="@+id/dutyTitle"
|
||||
android:layout_toEndOf="@+id/dutyTitle"
|
||||
android:stateListAnimator="@null"
|
||||
|
||||
android:text="@string/addDuty" />
|
||||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:id="@+id/userNoteLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/userNoteTitle"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_marginStart="30dp"
|
||||
android:layout_marginEnd="30dp"
|
||||
android:layout_marginTop="15dp"
|
||||
app:counterEnabled="true"
|
||||
app:counterMaxLength="1000">
|
||||
|
||||
<android.support.design.widget.TextInputEditText
|
||||
android:id="@+id/userNote"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="100dp"
|
||||
android:layout_alignStart="@+id/userNoteLayout"
|
||||
android:hint="@string/tutorTabHint"
|
||||
android:inputType="textMultiLine"
|
||||
android:lineSpacingExtra="8sp"
|
||||
android:maxLength="1000"
|
||||
android:maxLines="7"
|
||||
android:paddingTop="15dp"
|
||||
android:requiresFadingEdge="vertical"
|
||||
android:scrollbars="vertical"
|
||||
android:textColor="@color/note_list_text" />
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
|
||||
<android.support.v7.widget.AppCompatButton
|
||||
android:id="@+id/scrapTutorTab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignBaseline="@+id/personalInfoTitle"
|
||||
android:layout_alignEnd="@+id/userEmailLayout"
|
||||
android:textColor="@color/white"
|
||||
app:backgroundTint="@color/colorPrimary"
|
||||
android:stateListAnimator="@null"
|
||||
android:text="@string/scrap_tutor_tab" />
|
||||
|
||||
<android.support.v7.widget.AppCompatButton
|
||||
android:id="@+id/saveButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="30dp"
|
||||
android:layout_marginEnd="-20dp"
|
||||
android:layout_below="@+id/userNoteLayout"
|
||||
android:layout_alignEnd="@+id/dutyHourView"
|
||||
android:textColor="@color/white"
|
||||
app:backgroundTint="@color/colorPrimary"
|
||||
android:stateListAnimator="@null"
|
||||
|
||||
android:text="@string/saveButton" />
|
||||
|
||||
</RelativeLayout>
|
||||
</android.support.v4.widget.NestedScrollView>
|
@ -28,20 +28,6 @@
|
||||
android:textColor="@color/msg_no_notes"
|
||||
android:textSize="@dimen/msg_no_notes" />
|
||||
|
||||
<com.github.ybq.android.spinkit.SpinKitView
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/loader"
|
||||
style="@style/SpinKitView.Large.Wave"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="150dp"
|
||||
app:SpinKit_Color="@color/msg_no_notes"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="@dimen/margin_top_no_notes"
|
||||
android:fontFamily="sans-serif-light"
|
||||
android:text="@string/loading"
|
||||
android:textColor="@color/msg_no_notes"
|
||||
android:textSize="@dimen/msg_no_notes" />
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
@ -33,9 +33,7 @@
|
||||
android:inputType="text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:text="@tools:sample/date/hhmm"
|
||||
android:focusableInTouchMode="false"
|
||||
/>
|
||||
tools:text="@tools:sample/date/hhmm" />
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
@ -50,9 +48,7 @@
|
||||
android:inputType="text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:text="@tools:sample/date/hhmm"
|
||||
android:focusableInTouchMode="false"
|
||||
/>
|
||||
tools:text="@tools:sample/date/hhmm" />
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
|
||||
<ImageButton
|
||||
|
@ -1,22 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/pref_screen"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
<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:layout_height="match_parent"
|
||||
android:fontFamily="@font/lato_regular">
|
||||
android:fontFamily="@font/lato_regular"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="category_sharing"
|
||||
android:title="@string/settings_category_location">
|
||||
android:title="@string/settings_category_location"
|
||||
android:key="category_sharing">
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:disableDependentsState="false"
|
||||
android:key="key_sharing_enabled"
|
||||
android:persistent="true"
|
||||
android:title="@string/title_sharing" />
|
||||
android:title="@string/title_sharing"/>
|
||||
<ListPreference
|
||||
android:defaultValue="2"
|
||||
android:defaultValue="1"
|
||||
android:dialogTitle="@string/settings_location_level"
|
||||
android:entries="@array/location_level_entries"
|
||||
android:entryValues="@array/location_level_values"
|
||||
@ -25,30 +25,23 @@
|
||||
android:title="@string/title_location_level" />
|
||||
<ListPreference
|
||||
android:defaultValue="0"
|
||||
android:entries="@array/manual_location_entries"
|
||||
android:entryValues="@array/manual_location_values"
|
||||
android:key="key_manual_location_value"
|
||||
android:summary="%s"
|
||||
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>
|
||||
|
||||
<PreferenceCategory android:title="@string/settings_category_status">
|
||||
<SwitchPreference
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:disableDependentsState="false"
|
||||
android:key="key_status_enabled"
|
||||
android:persistent="true"
|
||||
android:title="@string/status_switch_title" />
|
||||
android:title="@string/status_switch_title"/>
|
||||
<ListPreference
|
||||
android:defaultValue="0"
|
||||
android:entries="@array/status_entries"
|
||||
android:entryValues="@array/status_values"
|
||||
android:defaultValue="2"
|
||||
android:key="@string/key_status_value"
|
||||
android:summary="%s"
|
||||
android:title="@string/status_list_title" />
|
||||
@ -56,12 +49,10 @@
|
||||
android:key="key_manual_status"
|
||||
android:selectAllOnFocus="true"
|
||||
android:singleLine="true"
|
||||
android:title="@string/title_manual_status" />
|
||||
<com.uam.wmi.findmytutor.utils.RightButtonPreference
|
||||
android:key="remove_manual_status"
|
||||
android:textColor="@color/white"
|
||||
app:backgroundTint="@color/mapboxRedDark"
|
||||
android:text="@string/preference_manual_status_button_remove" />
|
||||
|
||||
android:title="@string/title_manual_status"
|
||||
/>
|
||||
</PreferenceCategory>
|
||||
|
||||
|
||||
|
||||
</PreferenceScreen>
|
@ -1,23 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="right"
|
||||
android:fontFamily="@font/lato_regular"
|
||||
>
|
||||
|
||||
<android.support.v7.widget.AppCompatButton
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<Button xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/button_choose_from_map"
|
||||
android:text="@string/preference_manual_location_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:textColor="@color/white"
|
||||
app:backgroundTint="@color/top_user_modal"
|
||||
android:layout_height="wrap_content"
|
||||
android:stateListAnimator="@null"
|
||||
|
||||
/>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -19,22 +19,11 @@
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginTop="10dp"
|
||||
|
||||
android:textColor="@color/note_list_text"
|
||||
android:textSize="15sp" />
|
||||
|
||||
|
||||
<com.github.ybq.android.spinkit.SpinKitView xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/loader"
|
||||
style="@style/SpinKitView.Large.Wave"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginTop="35dp"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
app:SpinKit_Color="@color/colorAccent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/lastSeen"
|
||||
android:id="@+id/lastName"
|
||||
android:layout_width="270dp"
|
||||
android:layout_height="22dp"
|
||||
android:layout_marginStart="12dp"
|
||||
@ -43,8 +32,9 @@
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginEnd="0dp"
|
||||
android:layout_alignParentStart="true"
|
||||
android:textColor="#979797"
|
||||
android:textSize="13sp" />
|
||||
android:textColor="@color/note_list_text"
|
||||
android:textSize="15sp" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/isOnline"
|
||||
|
@ -32,15 +32,12 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:drawablePadding="10dp"
|
||||
android:gravity="center_horizontal"
|
||||
android:text="Name Surname"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/lbl_new_note_title"
|
||||
android:textStyle="normal"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
@ -51,28 +48,6 @@
|
||||
android:layout_marginTop="25dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/user_status_label_linearLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="gone"
|
||||
android:paddingLeft="20dp">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="25dp"
|
||||
android:src="@drawable/user_modal_title" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/user_status_label"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:paddingLeft="10dp"
|
||||
android:textColor="@color/mapboxWhite" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@ -82,15 +57,15 @@
|
||||
<ImageView
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="25dp"
|
||||
android:src="@drawable/user_modal_department" />
|
||||
|
||||
android:src="@drawable/user_modal_department"/>
|
||||
<TextView
|
||||
android:id="@+id/userDepartment"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:textColor="@color/mapboxWhite"
|
||||
android:paddingLeft="10dp"
|
||||
android:textColor="@color/mapboxWhite" />
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
@ -103,15 +78,15 @@
|
||||
<ImageView
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="25dp"
|
||||
android:src="@drawable/user_modal_room" />
|
||||
|
||||
android:src="@drawable/user_modal_room"/>
|
||||
<TextView
|
||||
android:id="@+id/userRoom"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:textColor="@color/mapboxWhite"
|
||||
android:paddingLeft="10dp"
|
||||
android:textColor="@color/mapboxWhite" />
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
@ -124,15 +99,15 @@
|
||||
<ImageView
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="25dp"
|
||||
android:src="@drawable/user_modal_email" />
|
||||
|
||||
android:src="@drawable/user_modal_email"/>
|
||||
<TextView
|
||||
android:id="@+id/userEmail"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:textColor="@color/mapboxWhite"
|
||||
android:paddingLeft="10dp"
|
||||
android:textColor="@color/mapboxWhite" />
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
@ -146,14 +121,15 @@
|
||||
<ImageView
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="25dp"
|
||||
android:src="@drawable/user_modal_duty" />
|
||||
android:src="@drawable/user_modal_duty"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/userDutyHoursTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/mapboxWhite"
|
||||
android:paddingLeft="10dp"
|
||||
android:textColor="@color/mapboxWhite" />
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
@ -173,11 +149,12 @@
|
||||
android:id="@+id/userDutyHours"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:divider="@color/background_user_modal"
|
||||
android:dividerHeight="1dp"
|
||||
android:paddingLeft="25dp"
|
||||
android:paddingTop="-10dp"
|
||||
android:textColor="@color/mapboxWhite" />
|
||||
android:divider="@color/background_user_modal"
|
||||
android:dividerHeight="1dp"
|
||||
android:textColor="@color/mapboxWhite"
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
@ -190,15 +167,15 @@
|
||||
<ImageView
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="25dp"
|
||||
android:src="@drawable/user_modal_note" />
|
||||
|
||||
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"
|
||||
android:textColor="@color/mapboxWhite" />
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
|
@ -27,20 +27,5 @@
|
||||
android:textSize="@dimen/msg_no_notes" />
|
||||
|
||||
|
||||
<com.github.ybq.android.spinkit.SpinKitView
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/loader"
|
||||
style="@style/SpinKitView.Large.Wave"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="150dp"
|
||||
app:SpinKit_Color="@color/msg_no_notes"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="@dimen/margin_top_no_notes"
|
||||
android:fontFamily="sans-serif-light"
|
||||
android:text="@string/loading"
|
||||
android:textColor="@color/msg_no_notes"
|
||||
android:textSize="@dimen/msg_no_notes" />
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
@ -1,11 +0,0 @@
|
||||
<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.TutorTab">
|
||||
<item
|
||||
android:id="@+id/action_profile_info_popup"
|
||||
android:orderInCategory="100"
|
||||
android:title="Popup info icon"
|
||||
android:icon="@drawable/outline_info_24"
|
||||
app:showAsAction="ifRoom" />
|
||||
</menu>
|
@ -57,7 +57,7 @@
|
||||
<string name="navigation_item_blacklist">Czarna lista</string>
|
||||
<string name="navigation_item_whitelist">Biała lista</string>
|
||||
<string name="navigation_item_settings">Ustawienia</string>
|
||||
<string name="navigation_item_profile">Profil użytkownika</string>
|
||||
<string name="navigation_item_profile">Profil uzytkownika</string>
|
||||
<string name="navigation_item_logout">Wyloguj</string>
|
||||
<!-- Tutors list -->
|
||||
<string name="action_settings">Ustawienia</string>
|
||||
@ -243,9 +243,6 @@
|
||||
<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>
|
||||
@ -268,31 +265,6 @@
|
||||
<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>
|
||||
<string name="floor">Piętro</string>
|
||||
<string name="block_the_users">Zablokuj użytkowników</string>
|
||||
<string name="be_visible_for_these_users">Bądź dostępny dla użytkowników</string>
|
||||
|
||||
<string name="manual_mode">manualny</string>
|
||||
<string name="exact_mode">dokładny</string>
|
||||
<string name="approx_mode">przybliżony</string>
|
||||
<string name="other_location">Niezapisana lokalizacja.</string>
|
||||
<string name="last_sign">Ostatnio</string>
|
||||
|
||||
<string name="available_now">Dostępny teraz</string>
|
||||
<string name="profile_activity_title">Profil użytkownika</string>
|
||||
<string name="batter_exclusions_title">Uwaga</string>
|
||||
<string name="batter_exclusions_message">Aby aplikacja była w pełni funkcjonalna, dodaj FMT do wyjątków w oszczędzaniu baterii. Po wciśnięciu przycisku \"ok\" zostaniesz przeniesiony do opcji zarządzania baterią. W panelu \"Bateria\" upewnij się, że opcja optymalizacji jest wyłączona.</string>
|
||||
|
||||
<string name="never_logged_in">Nigdy</string>
|
||||
|
||||
|
||||
</resources>
|
||||
|
||||
|
@ -55,15 +55,23 @@
|
||||
</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>
|
||||
@ -73,19 +81,4 @@
|
||||
<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>
|
||||
|
@ -54,10 +54,12 @@
|
||||
|
||||
|
||||
<!-- 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>
|
||||
@ -68,9 +70,6 @@
|
||||
<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>
|
||||
|
||||
@ -88,10 +87,14 @@
|
||||
<string name="title_manual_status">Add custom status</string>
|
||||
|
||||
|
||||
<string name="settings_description">Description</string>
|
||||
<string name="settings_description">Descrition</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>
|
||||
@ -126,6 +129,7 @@
|
||||
<string name="title_activity_settings2">Settings</string>
|
||||
<string name="modal_location_send">SEND</string>
|
||||
<string name="modal_location_hint">Please name choosen location.</string>
|
||||
modal_feedback_send
|
||||
<!-- Strings related to Settings -->
|
||||
|
||||
<!-- Example General settings -->
|
||||
@ -222,9 +226,9 @@
|
||||
<string name="nav_profile">User profile</string>
|
||||
<string name="remove_manual_location">Remove Manual location</string>
|
||||
<string name="title_activity_tutor_tab">TutorTab</string>
|
||||
<string name="manual_modal_title">Manual localization</string>
|
||||
<string name="lbl_ok">Save</string>
|
||||
<string name="lbl_cancel">Cancel</string>
|
||||
<string name="manual_modal_title">Do you want to save this localization?</string>
|
||||
<string name="lbl_ok">Save!</string>
|
||||
<string name="lbl_cancel">Cancel!</string>
|
||||
<string name="manual_marker_info">Your marker will disappear in next couple minutes</string>
|
||||
<string name="manual_location_selected">Manual Locations selected!</string>
|
||||
<string name="location_saved">Location saved!</string>
|
||||
@ -298,64 +302,7 @@
|
||||
<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-->
|
||||
<string name="profile_activity_title">Profile</string>
|
||||
<string name="hint_duty_day">Day</string>
|
||||
<string name="hint_duty_start">Start</string>
|
||||
<string name="hint_duty_end">End</string>
|
||||
<string name="hint_department">Department</string>
|
||||
<string name="hint_room">Room</string>
|
||||
<string name="hint_email" translatable="false">Email</string>
|
||||
<string name="addDuty">ADD DUTY</string>
|
||||
<string name="dutyTitle">Duty hours</string>
|
||||
<string name="personalInfoTitle">Personal info</string>
|
||||
<string name="userNoteTitle">Your note</string>
|
||||
<string name="updateToast">Thank you for updating your profile.</string>
|
||||
<string name="negative_dialog_button">No</string>
|
||||
<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 from WMI</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 active 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">Name the 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>
|
||||
<string name="floor">Floor</string>
|
||||
<string name="block_the_users">Block the users</string>
|
||||
<string name="be_visible_for_these_users">Be visible for these users</string>
|
||||
<string name="title_activity_scrolling">ScrollingActivity</string>
|
||||
<string name="large_text">
|
||||
<string name="large_text" translatable="false">
|
||||
"Material is the metaphor.\n\n"
|
||||
|
||||
"A material metaphor is the unifying theory of a rationalized space and a system of motion."
|
||||
@ -445,18 +392,49 @@
|
||||
"when a user tries to pick up one of cards.\n\n"
|
||||
</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) Sharing Modes -->
|
||||
<string name="manual_mode">manual</string>
|
||||
<string name="exact_mode">exact</string>
|
||||
<string name="approx_mode">approximate</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-->
|
||||
<string name="hint_duty_day">Day</string>
|
||||
<string name="hint_duty_start">Start</string>
|
||||
<string name="hint_duty_end">End</string>
|
||||
<string name="hint_department">Department</string>
|
||||
<string name="hint_room">Room</string>
|
||||
<string name="hint_email" translatable="false">Email</string>
|
||||
<string name="addDuty">ADD DUTY</string>
|
||||
<string name="dutyTitle">Duty hours</string>
|
||||
<string name="personalInfoTitle">Personal info</string>
|
||||
<string name="userNoteTitle">Your note</string>
|
||||
<string name="updateToast">Thank you for updating your profile.</string>
|
||||
<string name="negative_dialog_button">No</string>
|
||||
<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">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>
|
||||
|
||||
<!--(ENG) Undefined manual -->
|
||||
<string name="other_location">Not saved location.</string>
|
||||
<string name="user_status_label" translatable="false">Status</string>
|
||||
<string name="available_now">Available now</string>
|
||||
<string name="last_sign">Last seen</string>
|
||||
<string name="batter_exclusions_message">To make app fully functional add FMT to battery saving exclusions. You can change battery options in \"Optimise battery usage\". Unfortunately, you have to do it manually. Click \"ok\" to open battery settings and make sure that the application is not optimised.</string>
|
||||
<string name="batter_exclusions_title">Please note</string>
|
||||
<string name="never_logged_in">Never</string>
|
||||
</resources>
|
||||
|
@ -8,6 +8,7 @@ buildscript {
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.2.1'
|
||||
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
|
Loading…
Reference in New Issue
Block a user