Compare commits
29 Commits
Author | SHA1 | Date | |
---|---|---|---|
f5fd438219 | |||
99c84dee1b | |||
bab0999677 | |||
58f77ab6dc | |||
9eb97799cd | |||
6d5a32f006 | |||
a1c390d245 | |||
89c6e9bb4f | |||
ef670550d6 | |||
942970c740 | |||
52747d3ed6 | |||
ecdd1adf4e | |||
f389b0e1f4 | |||
5770bff725 | |||
5982e650e9 | |||
c6c492cd77 | |||
c49f8142da | |||
056c21d352 | |||
6c66b6d975 | |||
4c408b1035 | |||
b47537f0b6 | |||
f1dbe33eec | |||
f433aa26d5 | |||
906a0db310 | |||
56f03bc5fe | |||
ae86e21117 | |||
5a949cfcd0 | |||
0092de8376 | |||
01c75bf96d |
@ -3,6 +3,9 @@
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<compositeConfiguration>
|
||||
<compositeBuild compositeDefinitionSource="SCRIPT" />
|
||||
</compositeConfiguration>
|
||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="modules">
|
||||
|
@ -10,7 +10,7 @@ android {
|
||||
applicationId "com.uam.wmi.findmytutor"
|
||||
minSdkVersion 22
|
||||
targetSdkVersion 27
|
||||
versionCode 66
|
||||
versionCode 81
|
||||
versionName "1.0.0"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
@ -76,5 +76,7 @@ dependencies {
|
||||
// spinner loaders library
|
||||
implementation 'com.github.ybq:Android-SpinKit:1.2.0'
|
||||
// rx binding
|
||||
implementation 'com.jakewharton.rxbinding:rxbinding:0.3.0'
|
||||
implementation 'com.jakewharton.rxbinding:rxbinding:0.4.0'
|
||||
implementation 'com.jakewharton.rxbinding:rxbinding-appcompat-v7:0.4.0'
|
||||
implementation 'com.jakewharton.rxbinding:rxbinding-support-v4:0.4.0'
|
||||
}
|
||||
|
Binary file not shown.
Binary file not shown.
@ -14,6 +14,7 @@ import org.acra.annotation.AcraLimiter;
|
||||
import org.acra.annotation.AcraNotification;
|
||||
import org.acra.config.CoreConfigurationBuilder;
|
||||
import org.acra.config.HttpSenderConfigurationBuilder;
|
||||
import org.acra.config.LimiterConfigurationBuilder;
|
||||
import org.acra.config.ToastConfigurationBuilder;
|
||||
import org.acra.data.StringFormat;
|
||||
import org.acra.sender.HttpSender;
|
||||
@ -36,13 +37,13 @@ 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)
|
||||
//@AcraLimiter(failedReportLimit = 2)
|
||||
public class FindMyTutor extends Application {
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context base) {
|
||||
super.attachBaseContext(base);
|
||||
//super.attachBaseContext(LocaleHelper.onAttach(base));
|
||||
//super.attachBaseConteattachBaseContextxt(LocaleHelper.onAttach(base));
|
||||
|
||||
// ACRA core
|
||||
CoreConfigurationBuilder builder = new CoreConfigurationBuilder(this)
|
||||
@ -73,6 +74,10 @@ public class FindMyTutor extends Application {
|
||||
.setHttpHeaders(header)
|
||||
.setEnabled(true);
|
||||
|
||||
// builder.getPluginConfigurationBuilder(LimiterConfigurationBuilder.class)
|
||||
// .setFailedReportLimit(2)
|
||||
// .setEnabled(true);
|
||||
|
||||
ACRA.init(this, builder);
|
||||
//Shared preferences
|
||||
ACRA.getErrorReporter().putCustomData("USER_ID", sharedPreferences.getString("USER_ID", "no user id"));
|
||||
|
@ -9,6 +9,7 @@ import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.location.LocationManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
@ -35,17 +36,18 @@ import android.widget.Toast;
|
||||
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.EnableLocalization;
|
||||
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;
|
||||
|
||||
import com.uam.wmi.findmytutor.utils.SharingLevel;
|
||||
import com.uam.wmi.findmytutor.utils.WifiUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
@ -54,8 +56,6 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.functions.Function;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
|
||||
import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext;
|
||||
import static com.uam.wmi.findmytutor.utils.Const.defaultMapZoom;
|
||||
import static com.uam.wmi.findmytutor.utils.Const.onlineBackgroundLocationInterval;
|
||||
import static com.uam.wmi.findmytutor.utils.Const.searchMapZoom;
|
||||
@ -70,24 +70,20 @@ public abstract class BaseActivity
|
||||
private static final String[] REQUIRED_SDK_PERMISSIONS = new String[]{
|
||||
Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS};
|
||||
public DrawerLayout drawerLayout;
|
||||
public ActiveFragment activeFragment = ActiveFragment.NONE;
|
||||
public SearchView searchView;
|
||||
public MenuItem infoMenuItem;
|
||||
protected BottomNavigationView navigationView;
|
||||
protected NavigationView drawerNavigationView;
|
||||
protected DrawerLayout sideDrawer;
|
||||
protected Toolbar toolbar;
|
||||
protected boolean isTutor;
|
||||
|
||||
String tag = getClass().getName();
|
||||
|
||||
protected FeedbackUtils feedbackUtils;
|
||||
|
||||
String tag = getClass().getName();
|
||||
private ActionBarDrawerToggle actionBarDrawerToggle;
|
||||
private SharingFragment sharingFragment;
|
||||
|
||||
private Fragment userListFragment;
|
||||
public ActiveFragment activeFragment = ActiveFragment.NONE;
|
||||
private Fragment activeBottomMenu = null;
|
||||
public SearchView searchView;
|
||||
public MenuItem infoMenuItem;
|
||||
private Fragment activeBottomMenu = null;
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context base) {
|
||||
@ -111,33 +107,33 @@ public abstract class BaseActivity
|
||||
if (itemName.equals(getResources().getString(R.string.navigation_item_whitelist))) {
|
||||
launchIntent = new Intent(getApplicationContext(), WhiteList.class);
|
||||
startActivity(launchIntent);
|
||||
} else if (itemName.equals(getResources().getString(R.string.navigation_item_blacklist))) {
|
||||
launchIntent = new Intent(getApplicationContext(),BlackList.class);
|
||||
} else if (itemName.equals(getResources().getString(R.string.navigation_item_blacklist))) {
|
||||
launchIntent = new Intent(getApplicationContext(), BlackList.class);
|
||||
startActivity(launchIntent);
|
||||
|
||||
} else if (itemName.equals(getResources().getString(R.string.navigation_item_profile))) {
|
||||
} else if (itemName.equals(getResources().getString(R.string.navigation_item_profile))) {
|
||||
|
||||
launchIntent = new Intent(getApplicationContext(), TutorTab.class);
|
||||
startActivity(launchIntent);
|
||||
} else if (itemName.equals(getResources().getString(R.string.navigation_item_settings))) {
|
||||
} else if (itemName.equals(getResources().getString(R.string.navigation_item_settings))) {
|
||||
launchIntent = new Intent(getApplicationContext(), SettingsActivity.class);
|
||||
startActivity(launchIntent);
|
||||
|
||||
} else if (itemName.equals(getResources().getString(R.string.navigation_item_logout))) {
|
||||
if(PrefUtils.isBackgroundLocationServiceRunning(getApplicationContext())) {
|
||||
} else if (itemName.equals(getResources().getString(R.string.navigation_item_logout))) {
|
||||
if (PrefUtils.isBackgroundLocationServiceRunning(getApplicationContext())) {
|
||||
stopBackgroundLocalizationTask();
|
||||
}
|
||||
logout();
|
||||
|
||||
|
||||
} else if (itemName.equals(getResources().getString(R.string.navigation_item_feedback))) {
|
||||
feedbackUtils.showNoteDialog("FEEDBACK");
|
||||
} else if (itemName.equals(getResources().getString(R.string.navigation_item_feedback))) {
|
||||
feedbackUtils.showNoteDialog("FEEDBACK");
|
||||
|
||||
/*showNoteDialog(BaseActivity.this, );*/
|
||||
} else if (itemName.equals(getResources().getString(R.string.navigation_item_bug))) {
|
||||
feedbackUtils.showNoteDialog("BUG REPORT");
|
||||
/*showNoteDialog(BaseActivity.this, "BUG REPORT");*/
|
||||
}
|
||||
/*showNoteDialog(BaseActivity.this, );*/
|
||||
} else if (itemName.equals(getResources().getString(R.string.navigation_item_bug))) {
|
||||
feedbackUtils.showNoteDialog("BUG REPORT");
|
||||
/*showNoteDialog(BaseActivity.this, "BUG REPORT");*/
|
||||
}
|
||||
|
||||
sideDrawer.closeDrawers();
|
||||
|
||||
@ -159,7 +155,7 @@ public abstract class BaseActivity
|
||||
}
|
||||
|
||||
|
||||
protected void logout(){
|
||||
protected void logout() {
|
||||
storeBackgroundLocationStatus(getApplication(), false);
|
||||
PrefUtils.storeIsLoggedIn(getApplicationContext(), false);
|
||||
PrefUtils.setBatteryExlusionInfoStatus(getApplicationContext(), true);
|
||||
@ -193,6 +189,23 @@ public abstract class BaseActivity
|
||||
onRequestPermissionsResult(REQUEST_CODE_ASK_PERMISSIONS, REQUIRED_SDK_PERMISSIONS,
|
||||
grantResults);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void statusCheck() {
|
||||
final LocationManager manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
|
||||
|
||||
if (!Objects.requireNonNull(manager).isProviderEnabled(LocationManager.GPS_PROVIDER)) {
|
||||
buildAlertMessageNoGps();
|
||||
}
|
||||
}
|
||||
|
||||
private void buildAlertMessageNoGps() {
|
||||
EnableLocalization sharingDialog = new EnableLocalization();
|
||||
sharingDialog.show(getFragmentManager(), "Sharing");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -221,11 +234,22 @@ public abstract class BaseActivity
|
||||
stopIntent.putExtra("request_stop", true);
|
||||
|
||||
stopService(stopIntent);
|
||||
|
||||
}
|
||||
|
||||
public void startBackgroundLocalizationTask() {
|
||||
checkPermissions();
|
||||
|
||||
if (!PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.PRESENCE.toString())
|
||||
&& !PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.MANUAL.toString())
|
||||
) {
|
||||
statusCheck();
|
||||
}
|
||||
|
||||
if (!WifiUtils.checkIfUserIsInRangeOfWmiWifi(getApplicationContext())
|
||||
&& PrefUtils.getLocationLevel(getApplicationContext()).equals(SharingLevel.PRESENCE.toString())){
|
||||
statusCheck();
|
||||
}
|
||||
|
||||
PrefUtils.storeEnableSharingLocalization(getApplicationContext(), true);
|
||||
|
||||
Intent startIntent = new Intent(getApplicationContext(), BackgroundLocalizationService.class);
|
||||
@ -302,6 +326,16 @@ public abstract class BaseActivity
|
||||
MenuItem myActionMenuItem = menu.findItem(R.id.action_search);
|
||||
searchView = (SearchView) myActionMenuItem.getActionView();
|
||||
|
||||
RxSearchObservable.fromView(searchView)
|
||||
.skip(0)
|
||||
.map(String::toLowerCase)
|
||||
.filter(t -> !t.isEmpty())
|
||||
.debounce(250, TimeUnit.MILLISECONDS)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.switchMap((Function<String, ObservableSource<String>>) Observable::just)
|
||||
.subscribe(this::executeSearch);
|
||||
|
||||
searchView.setOnQueryTextFocusChangeListener((v, hasFocus) -> {
|
||||
if (!hasFocus && activeFragment.equals(ActiveFragment.NONE)) {
|
||||
restoreMapMarkers();
|
||||
@ -312,20 +346,12 @@ public abstract class BaseActivity
|
||||
((UsersListFragment) userListFragment).restoreUsersList();
|
||||
}
|
||||
|
||||
if(hasFocus && activeFragment.equals(ActiveFragment.NONE)){
|
||||
adjustMapToSearch(searchMapZoom);
|
||||
if (hasFocus && activeFragment.equals(ActiveFragment.NONE)) {
|
||||
adjustMapToSearch(searchMapZoom);
|
||||
}
|
||||
});
|
||||
|
||||
RxSearchObservable.fromView(searchView)
|
||||
.skip(0)
|
||||
.map(String::toLowerCase)
|
||||
.filter(t -> !t.isEmpty())
|
||||
.debounce(250, TimeUnit.MILLISECONDS)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.switchMap((Function<String, ObservableSource<String>>) Observable::just)
|
||||
.subscribe(this::executeSearch);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -351,9 +377,9 @@ public abstract class BaseActivity
|
||||
return true;
|
||||
}
|
||||
|
||||
if (item.getItemId()==R.id.action_info){
|
||||
if (item.getItemId() == R.id.action_info) {
|
||||
int layoutID;
|
||||
switch (activeFragment){
|
||||
switch (activeFragment) {
|
||||
case SHARED_PREFERENCES:
|
||||
layoutID = R.layout.info_popup_sharing_tab;
|
||||
break;
|
||||
@ -364,7 +390,7 @@ public abstract class BaseActivity
|
||||
layoutID = R.layout.info_popup_map;
|
||||
}
|
||||
|
||||
View popupView = getLayoutInflater().inflate(layoutID,null);
|
||||
View popupView = getLayoutInflater().inflate(layoutID, null);
|
||||
|
||||
PopupWindow popupWindow = new PopupWindow(popupView,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
@ -373,8 +399,8 @@ public abstract class BaseActivity
|
||||
// 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);
|
||||
View anchorView = getWindow().getDecorView().findViewById(android.R.id.content);
|
||||
popupWindow.showAtLocation(anchorView, Gravity.TOP | Gravity.END, 0, 0);
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
@ -453,9 +479,8 @@ public abstract class BaseActivity
|
||||
}
|
||||
|
||||
abstract int getNavigationMenuItemId();
|
||||
|
||||
abstract int getContentViewId();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -10,24 +10,24 @@ import android.os.Bundle;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
|
||||
import com.auth0.android.jwt.Claim;
|
||||
import com.auth0.android.jwt.JWT;
|
||||
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
|
||||
import com.jakewharton.rxbinding.widget.RxTextView;
|
||||
import com.jakewharton.rxbinding.widget.TextViewTextChangeEvent;
|
||||
import com.uam.wmi.findmytutor.R;
|
||||
import com.uam.wmi.findmytutor.model.JwtToken;
|
||||
import com.uam.wmi.findmytutor.model.LdapUser;
|
||||
import com.uam.wmi.findmytutor.model.User;
|
||||
import com.uam.wmi.findmytutor.model.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;
|
||||
|
||||
@ -35,6 +35,8 @@ import java.util.Objects;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
@ -42,7 +44,13 @@ import okhttp3.ResponseBody;
|
||||
|
||||
public class LoginActivity extends AppCompatActivity {
|
||||
|
||||
private AutoCompleteTextView mLoginNameView;
|
||||
@BindView(R.id.password)
|
||||
EditText password;
|
||||
@BindView(R.id.email)
|
||||
EditText email;
|
||||
@BindView(R.id.email_sign_in_button)
|
||||
Button sign_in_button;
|
||||
private EditText mLoginNameView;
|
||||
private EditText mPasswordView;
|
||||
private View mProgressView;
|
||||
private View mLoginFormView;
|
||||
@ -55,6 +63,7 @@ public class LoginActivity extends AppCompatActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_login);
|
||||
mLoginNameView = findViewById(R.id.email);
|
||||
ButterKnife.bind(this);
|
||||
|
||||
ldapService = ApiClient.getClient(getApplicationContext())
|
||||
.create(LdapService.class);
|
||||
@ -75,6 +84,30 @@ public class LoginActivity extends AppCompatActivity {
|
||||
|
||||
mLoginFormView = findViewById(R.id.login_form);
|
||||
mProgressView = findViewById(R.id.login_progress);
|
||||
|
||||
validateForm();
|
||||
}
|
||||
|
||||
|
||||
private void validateForm() {
|
||||
sign_in_button.setEnabled(false);
|
||||
mLoginNameView.setError(null);
|
||||
mPasswordView.setError(null);
|
||||
|
||||
rx.Observable<TextViewTextChangeEvent> emailChangeObservable = RxTextView.textChangeEvents(email);
|
||||
rx.Observable<TextViewTextChangeEvent> passwordChangeObservable = RxTextView.textChangeEvents(password);
|
||||
|
||||
rx.Observable.combineLatest(emailChangeObservable, passwordChangeObservable,
|
||||
(emailObservable, passwordObservable) -> {
|
||||
boolean emailCheck = isEmailValid(emailObservable.text());
|
||||
boolean passwordCheck = passwordObservable.text().length() > 0;
|
||||
|
||||
if (!emailCheck) {
|
||||
mLoginNameView.setError(getString(R.string.error_invalid_login_name));
|
||||
}
|
||||
|
||||
return emailCheck && passwordCheck;
|
||||
}).subscribe(aBoolean -> sign_in_button.setEnabled(aBoolean));
|
||||
}
|
||||
|
||||
|
||||
@ -117,7 +150,9 @@ public class LoginActivity extends AppCompatActivity {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isEmailValid(String loginName) {
|
||||
private boolean isEmailValid(CharSequence loginName) {
|
||||
|
||||
Log.e("AAA", String.valueOf(loginName));
|
||||
Pattern pattern = Pattern.compile("\\s");
|
||||
Matcher matcher = pattern.matcher(loginName);
|
||||
return !matcher.find();
|
||||
@ -127,7 +162,6 @@ public class LoginActivity extends AppCompatActivity {
|
||||
private void showProgress(final boolean show) {
|
||||
int shortAnimTime = getResources().getInteger(android.R.integer.config_shortAnimTime);
|
||||
|
||||
|
||||
mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
|
||||
mLoginFormView.animate().setDuration(shortAnimTime).alpha(
|
||||
show ? 0 : 1).setListener(new AnimatorListenerAdapter() {
|
||||
@ -217,5 +251,13 @@ public class LoginActivity extends AppCompatActivity {
|
||||
PrefUtils.storeUserLastName(getApplicationContext(), user.getLastName());
|
||||
PrefUtils.storeUserName(getApplicationContext(), user.getUserName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
mLoginNameView.setError(null);
|
||||
mPasswordView.setError(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -49,6 +49,7 @@ import com.uam.wmi.findmytutor.service.CoordinateService;
|
||||
import com.uam.wmi.findmytutor.service.PredefinedCoordinatesService;
|
||||
import com.uam.wmi.findmytutor.service.UserService;
|
||||
import com.uam.wmi.findmytutor.utils.ApproximatedLocalization;
|
||||
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.LocaleUtils;
|
||||
@ -150,7 +151,6 @@ public class MapActivity extends BaseActivity
|
||||
if(isTutor){
|
||||
MapUtils.BatteryOptimizationsExceptionCheck(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -221,7 +221,6 @@ public class MapActivity extends BaseActivity
|
||||
}
|
||||
|
||||
String sharingLevelToRender = sharingLevel;
|
||||
Log.e("LOCALE",PrefUtils.getLocale(getApplicationContext()));
|
||||
|
||||
if (PrefUtils.getLocale(getApplicationContext()).equals("pl") ||
|
||||
PrefUtils.getLocale(getApplicationContext()).equals("pl-PL") ||
|
||||
@ -340,19 +339,21 @@ Log.e("LOCALE",PrefUtils.getLocale(getApplicationContext()));
|
||||
public void showLocationDialog(LatLng latLng) {
|
||||
|
||||
LayoutInflater layoutInflaterAndroid = LayoutInflater.from(getApplicationContext());
|
||||
|
||||
@SuppressLint("InflateParams") View view = layoutInflaterAndroid.inflate(R.layout.location_modal, null);
|
||||
EditText modalUserInput = view.findViewById(R.id.manual_input);
|
||||
|
||||
AlertDialog.Builder alertDialogBuilderUserInput = new android.support.v7.app.AlertDialog.Builder(this);
|
||||
|
||||
alertDialogBuilderUserInput.setView(view).setPositiveButton(getApplicationContext().getString(R.string.modal_location_send), null);
|
||||
|
||||
alertDialogBuilderUserInput
|
||||
.setPositiveButton(R.string.lbl_ok, null)
|
||||
.setNegativeButton(R.string.lbl_cancel, null);
|
||||
.setPositiveButton(R.string.lbl_yes, null)
|
||||
.setNegativeButton(R.string.lbl_no, null)
|
||||
.setTitle(R.string.manual_modal_title);
|
||||
|
||||
final AlertDialog alertDialog = alertDialogBuilderUserInput.create();
|
||||
|
||||
EditText modalUserInput = view.findViewById(R.id.manual_input);
|
||||
|
||||
alertDialog.setOnShowListener(dialogInterface -> {
|
||||
Button sendButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
|
||||
Button dismissButton = alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE);
|
||||
@ -370,6 +371,8 @@ Log.e("LOCALE",PrefUtils.getLocale(getApplicationContext()));
|
||||
if (TextUtils.isEmpty(body)) {
|
||||
Toast.makeText(getApplicationContext(), getApplicationContext().getString(R.string.modal_location_hint), Toast.LENGTH_SHORT).show();
|
||||
modalUserInput.requestFocus();
|
||||
}else if (body.length() > Const.maxPredefinedCordNameLength){
|
||||
Toast.makeText(getApplicationContext(), getApplicationContext().getString(R.string.manual_location_tolong_error)+": "+Const.maxPredefinedCordNameLength, Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
sendLocation(body, latLng);
|
||||
PrefUtils.putCurrentManualLocationName(getApplicationContext(), body);
|
||||
@ -381,7 +384,6 @@ Log.e("LOCALE",PrefUtils.getLocale(getApplicationContext()));
|
||||
alertDialog.show();
|
||||
}
|
||||
|
||||
|
||||
private void sendLocation(String body, LatLng latLng) {
|
||||
PredefinedCoordinatesService predefinedCoordinatesService = ApiClient.getClient(getApplicationContext()).create(PredefinedCoordinatesService.class);
|
||||
|
||||
|
@ -3,7 +3,6 @@ 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;
|
||||
@ -12,6 +11,7 @@ import android.preference.Preference;
|
||||
import android.preference.PreferenceCategory;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.preference.SwitchPreference;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@ -23,22 +23,25 @@ import com.annimon.stream.Stream;
|
||||
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.model.StatusesListModel;
|
||||
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;
|
||||
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
import io.reactivex.observers.DisposableSingleObserver;
|
||||
@ -71,6 +74,8 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
||||
private String[] statusesArray;
|
||||
private boolean statusSwitchFlag;
|
||||
private ArrayList<String> predefinedLocationsList;
|
||||
private List<String> afterDeleted = new ArrayList<>();
|
||||
|
||||
|
||||
public static SharingFragment newInstance() {
|
||||
return new SharingFragment();
|
||||
@ -112,8 +117,8 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
||||
public void onSuccess(List<PredefinedCoordViewModel> coords) {
|
||||
|
||||
String currentCoordId = PrefUtils.getCurrentManualLocation(getApplicationContext());
|
||||
locationMap = new HashMap<String, String>();
|
||||
locationUUIDs = new ArrayList<String>();
|
||||
locationMap = new HashMap<>();
|
||||
locationUUIDs = new ArrayList<>();
|
||||
for (PredefinedCoordViewModel i : coords)
|
||||
locationMap.put(i.getPredefinedCoordinateId(), i.getName());
|
||||
for (PredefinedCoordViewModel i : coords)
|
||||
@ -175,16 +180,16 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
||||
locationService = ApiClient.getClient(getApplicationContext()).create(PredefinedCoordinatesService.class);
|
||||
disposable = new CompositeDisposable();
|
||||
statusesArray = new String[0];
|
||||
predefinedLocationsList = new ArrayList<String>();
|
||||
predefinedLocationsList = new ArrayList<>();
|
||||
getStatuses(disposable);
|
||||
getLocations(disposable);
|
||||
locationLevelMapping = new HashMap<Integer, String>();
|
||||
locationLevelMapping = new HashMap<>();
|
||||
locationLevelMapping.put(0, SharingLevel.PRESENCE.toString());
|
||||
locationLevelMapping.put(1, SharingLevel.APPROXIMATED.toString());
|
||||
locationLevelMapping.put(2, SharingLevel.EXACT.toString());
|
||||
locationLevelMapping.put(3, SharingLevel.MANUAL.toString());
|
||||
|
||||
statusMapping = new HashMap<Integer, String>();
|
||||
statusMapping = new HashMap<>();
|
||||
statusMapping.put(0, "available");
|
||||
statusMapping.put(1, "consultation");
|
||||
statusMapping.put(2, "busy");
|
||||
@ -202,9 +207,10 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
||||
|
||||
/** Sharing level list **/
|
||||
locationMode.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
PrefUtils.storeLocationMode(getApplicationContext(), locationLevelMapping.get(Integer.parseInt((String) 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()) {
|
||||
@ -262,23 +268,22 @@ 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;
|
||||
statusList.setOnPreferenceClickListener(preference -> {
|
||||
if (statusesArray.length == 0) {
|
||||
builder.setTitle("Status");
|
||||
}
|
||||
return true;
|
||||
});
|
||||
/** Custom status edittext change listener **/
|
||||
manualStatus.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
|
||||
disposable.add(statusesService.postUserPredefinedStatus(PrefUtils.getUserId(getApplicationContext()), (String) newValue)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(this::handleResponse, this::handleError));
|
||||
if (newValue.toString().length() > Const.maxStatusLength) {
|
||||
Toast.makeText(getApplicationContext(), getString(R.string.status_max_length) + " :"+Const.maxStatusLength, Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
disposable.add(statusesService.postUserPredefinedStatus(PrefUtils.getUserId(getApplicationContext()), (String) newValue)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(this::handleResponse, this::handleError));
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
@ -296,25 +301,19 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
||||
|
||||
public void showRemoveDialog(CharSequence[] entries, String service) {
|
||||
boolean[] checked = new boolean[entries.length];
|
||||
ArrayList<String> tobeDeleted = new ArrayList<String>();
|
||||
ArrayList<String> tobeDeleted = new ArrayList<>();
|
||||
// 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]);
|
||||
}
|
||||
builder.setPositiveButton(R.string.delete, (dialog, which) -> {
|
||||
for (int i = 0; i < entries.length; i++) {
|
||||
if (checked[i]) {
|
||||
tobeDeleted.add((String) entries[i]);
|
||||
}
|
||||
removeEntries(service, tobeDeleted);
|
||||
}
|
||||
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.setMultiChoiceItems(entries, checked, (dialog, which, isChecked) -> {
|
||||
|
||||
}
|
||||
});
|
||||
builder.create().show();
|
||||
}
|
||||
@ -329,13 +328,14 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
||||
|
||||
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));
|
||||
if (toBeDeleted.size() > 0){
|
||||
disposable.add(
|
||||
statusesService.deleteUserPredefinedStatus(PrefUtils.getUserId(getApplicationContext()), new StatusesListModel(toBeDeleted))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(this::handleDeleteStatuses, this::handleError)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
ArrayList<String> uuidsToBeDeleted = new ArrayList<String>();
|
||||
@ -347,7 +347,6 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
||||
}
|
||||
}
|
||||
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())
|
||||
@ -409,12 +408,13 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
||||
}
|
||||
|
||||
private void handleDeleteStatuses(List<String> resp) {
|
||||
// getStatuses(disposable);
|
||||
String currentEntry = PrefUtils.getUserStatus(getApplicationContext());
|
||||
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 {
|
||||
@ -505,4 +505,20 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
|
||||
disposable.dispose();
|
||||
}
|
||||
|
||||
private void showError(Throwable e) {
|
||||
String message;
|
||||
|
||||
if (e instanceof HttpException) {
|
||||
ResponseBody responseBody = ((HttpException) e).response().errorBody();
|
||||
message = RestApiHelper.getErrorMessage(responseBody);
|
||||
if (((HttpException) e).response().code() == 404) {
|
||||
message = getString(R.string.no_such_a_user);
|
||||
}
|
||||
} else {
|
||||
message = "Network Error !";
|
||||
}
|
||||
Log.e("ERR", message);
|
||||
Toast.makeText(getApplicationContext(), message, Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -28,11 +28,15 @@ 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.Const;
|
||||
import com.uam.wmi.findmytutor.utils.LocaleHelper;
|
||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||
import com.uam.wmi.findmytutor.utils.RestApiHelper;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@ -197,20 +201,20 @@ public class TutorTab extends AppCompatActivity {
|
||||
|
||||
private void setUpSaveListener(Button button) {
|
||||
button.setOnClickListener(view -> {
|
||||
if( isEmailValid(userEmail.getText().toString())){
|
||||
if (isFormValid()){
|
||||
newTab = new TutorTabViewModel(PrefUtils.getUserId(getApplicationContext()),
|
||||
userRoom.getText().toString(),
|
||||
userEmail.getText().toString(),
|
||||
userNote.getText().toString(),
|
||||
dutyHoursAdapter.getDutyList());
|
||||
Log.e("kurwo",newTab.toString());
|
||||
|
||||
if(ifTutorTabExists){
|
||||
putUserTab(newTab);
|
||||
}else{
|
||||
}else {
|
||||
postUserTab(newTab);
|
||||
ifTutorTabExists=true;
|
||||
ifTutorTabExists = true;
|
||||
}
|
||||
}else{
|
||||
userEmail.setError(getString(R.string.error_invalid_email));
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -283,6 +287,48 @@ public class TutorTab extends AppCompatActivity {
|
||||
super.attachBaseContext(LocaleHelper.onAttach(base));
|
||||
}
|
||||
|
||||
public boolean isFormValid(){
|
||||
boolean emailOK = isEmailValid(userEmail.getText().toString());
|
||||
if (!emailOK) {
|
||||
userEmail.setError(getString(R.string.error_invalid_email));
|
||||
}
|
||||
boolean userRoomOK = userRoom.getText().toString().length() < Const.maxRoomLength;
|
||||
if (!userRoomOK){
|
||||
userRoom.setError(getString(R.string.max_room_lenth_error)+": "+Const.maxRoomLength);
|
||||
}
|
||||
boolean userNoteOK = userNote.getText().toString().length() < Const.maxNoteLength;
|
||||
if (!userNoteOK){
|
||||
userNote.setError(getString(R.string.max_note_length_error)+ ": "+Const.maxNoteLength);
|
||||
}
|
||||
|
||||
boolean dutyHoursAdapterOK = true;
|
||||
for (DutyHourViewModel oo:
|
||||
dutyHoursAdapter.getDutyList()) {
|
||||
// TIME
|
||||
SimpleDateFormat format = new SimpleDateFormat("HH:mm");
|
||||
Date start, end = null;
|
||||
try {
|
||||
start = format.parse(oo.getStart());
|
||||
end = format.parse(oo.getEnd());
|
||||
if (start.compareTo(end) > 0) {
|
||||
Toast.makeText(getApplicationContext(), R.string.end_b4_start_error, Toast.LENGTH_LONG).show();
|
||||
dutyHoursAdapterOK = false;
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// DAY
|
||||
boolean dayOK = oo.getDay().length() < Const.maxDayLength;
|
||||
if (!dayOK){
|
||||
Toast.makeText(getApplicationContext(), getString(R.string.max_day_length_error) + ": " + Const.maxDayLength, Toast.LENGTH_LONG).show();
|
||||
dutyHoursAdapterOK = false;
|
||||
}
|
||||
}
|
||||
|
||||
return emailOK && userRoomOK && userNoteOK && dutyHoursAdapterOK;
|
||||
}
|
||||
|
||||
public boolean isEmailValid(String email)
|
||||
{
|
||||
String regExpn =
|
||||
|
@ -13,9 +13,11 @@ 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.Html;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.format.DateFormat;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.text.style.ImageSpan;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
@ -29,6 +31,7 @@ import android.widget.ArrayAdapter;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
import com.github.ybq.android.spinkit.SpinKitView;
|
||||
@ -272,7 +275,9 @@ public class UsersListFragment extends Fragment {
|
||||
}
|
||||
|
||||
userRoom.setText(String.format("%s: %s", getString(R.string.userRoom), tutorTabViewModel.getRoom()));
|
||||
userEmail.setText(String.format("%s: %s", getString(R.string.userEmail), tutorTabViewModel.getEmailTutorTab()));
|
||||
userEmail.setText(Html.fromHtml("Email: <a href=\""+tutorTabViewModel.getEmailTutorTab()+"\">"+tutorTabViewModel.getEmailTutorTab() +"</a>"));
|
||||
userEmail.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
|
||||
userNote.setText(String.format("%s: %s", getString(R.string.userNote), userNoteText));
|
||||
department.setText(String.format("%s: %s", getString(R.string.userDepartment), user.getDepartment()));
|
||||
userDutyHoursTitle.setText(String.format("%s:", getString(R.string.userDutyHoursHeader)));
|
||||
@ -383,6 +388,14 @@ public class UsersListFragment extends Fragment {
|
||||
if (e instanceof HttpException) {
|
||||
ResponseBody responseBody = ((HttpException) e).response().errorBody();
|
||||
message = RestApiHelper.getErrorMessage(responseBody);
|
||||
if(((HttpException) e).response().code() == 404){
|
||||
if (PrefUtils.getLocale(getApplicationContext()).equals("pl") ||
|
||||
PrefUtils.getLocale(getApplicationContext()).equals("pl-PL") ||
|
||||
PrefUtils.getLocale(getApplicationContext()).equals("[pl-PL]")) {
|
||||
message = getString(R.string.no_tutor_tab);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
message = getString(R.string.network_err);
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ import com.uam.wmi.findmytutor.model.IsUsingListBool;
|
||||
import com.uam.wmi.findmytutor.model.StudentIdModel;
|
||||
import com.uam.wmi.findmytutor.model.User;
|
||||
import com.uam.wmi.findmytutor.network.ApiClient;
|
||||
import com.uam.wmi.findmytutor.service.UserService;
|
||||
import com.uam.wmi.findmytutor.service.WhiteListService;
|
||||
import com.uam.wmi.findmytutor.utils.LocaleHelper;
|
||||
import com.uam.wmi.findmytutor.utils.MyDividerItemDecoration;
|
||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||
@ -51,16 +51,14 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.ObservableSource;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.functions.Function;
|
||||
import io.reactivex.observers.DisposableObserver;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.ResponseBody;
|
||||
|
||||
@ -80,7 +78,7 @@ public class WhiteList extends AppCompatActivity {
|
||||
|
||||
|
||||
private CompositeDisposable disposable = new CompositeDisposable();
|
||||
private UserService userService;
|
||||
private WhiteListService whiteListService;
|
||||
private boolean didFetched = false;
|
||||
private String tutorId;
|
||||
private WhiteListAdapter mAdapter;
|
||||
@ -102,8 +100,8 @@ public class WhiteList extends AppCompatActivity {
|
||||
ButterKnife.bind(this);
|
||||
|
||||
tutorId = PrefUtils.getUserId(getApplicationContext());
|
||||
userService = ApiClient.getClient(getApplicationContext())
|
||||
.create(UserService.class);
|
||||
whiteListService = ApiClient.getClient(getApplicationContext())
|
||||
.create(WhiteListService.class);
|
||||
|
||||
if (PrefUtils.isWhiteListing(this)) {
|
||||
aSwitch.setText(getString(R.string.action_white_list) +" "+getString(R.string.on) );
|
||||
@ -148,14 +146,14 @@ public class WhiteList extends AppCompatActivity {
|
||||
}
|
||||
|
||||
private Observable<List<String>> getListOfWhitelistedUsers(String userId) {
|
||||
return userService.getTutorWhitelistedByID(userId)
|
||||
return whiteListService.getTutorWhitelist(userId)
|
||||
.toObservable()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
private Observable<User> getUserObservable(String userId) {
|
||||
return userService
|
||||
return whiteListService
|
||||
.getUserById(userId)
|
||||
.toObservable()
|
||||
.subscribeOn(Schedulers.io())
|
||||
@ -169,7 +167,10 @@ public class WhiteList extends AppCompatActivity {
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.flatMap(Observable::fromIterable)
|
||||
.flatMap(this::getUserObservable)
|
||||
.subscribe(user -> whitelistedUsers.add(user), this::handleError,this::handleComplete));
|
||||
.subscribe(user -> whitelistedUsers.add(user),
|
||||
this::handleError,
|
||||
this::handleComplete)
|
||||
);
|
||||
}
|
||||
|
||||
private void handleDoOnSubscribe(Disposable disposable) {
|
||||
@ -210,7 +211,7 @@ public class WhiteList extends AppCompatActivity {
|
||||
.setNegativeButton(R.string.cancel, null);
|
||||
|
||||
final AlertDialog alertDialog = alertDialogBuilderUserInput.create();
|
||||
alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
|
||||
Objects.requireNonNull(alertDialog.getWindow()).setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
|
||||
|
||||
EditText modalUserInput = view.findViewById(R.id.white_list_modal_input);
|
||||
|
||||
@ -241,7 +242,7 @@ public class WhiteList extends AppCompatActivity {
|
||||
StudentIdModel studentIdModel = new StudentIdModel(body);
|
||||
|
||||
disposable.add(
|
||||
userService.addStudentToWhitelist(tutorId, studentIdModel)
|
||||
whiteListService.addStudentToWhitelist(tutorId, studentIdModel)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(this::handleAddUser, this::showError)
|
||||
@ -326,7 +327,7 @@ public class WhiteList extends AppCompatActivity {
|
||||
IsUsingListBool isUsingListBool = new IsUsingListBool();
|
||||
isUsingListBool.setIsUsing(value);
|
||||
disposable.add(
|
||||
userService.setTutorWhitelist(tutorId, isUsingListBool)
|
||||
whiteListService.setTutorWhitelist(tutorId, isUsingListBool)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(() -> {
|
||||
|
@ -0,0 +1,27 @@
|
||||
package com.uam.wmi.findmytutor.model;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class StatusesListModel
|
||||
{
|
||||
@SerializedName("statusesList")
|
||||
@Expose
|
||||
public List<String> statusesList;
|
||||
|
||||
public StatusesListModel(){}
|
||||
|
||||
public StatusesListModel(List<String> _statusesList){
|
||||
this.statusesList = _statusesList;
|
||||
}
|
||||
|
||||
public List<String> getStatusesList() {
|
||||
return statusesList;
|
||||
}
|
||||
|
||||
public void setStatusesList(List<String> statusesList) {
|
||||
this.statusesList = statusesList;
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Color;
|
||||
@ -21,6 +22,7 @@ import android.os.Looper;
|
||||
import android.support.annotation.RequiresApi;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.util.Log;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
@ -35,6 +37,7 @@ 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.EnableSharingDialog;
|
||||
import com.uam.wmi.findmytutor.utils.MapUtils;
|
||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||
import com.uam.wmi.findmytutor.utils.SharingLevel;
|
||||
@ -44,6 +47,7 @@ import org.apache.commons.collections4.queue.CircularFifoQueue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
|
@ -1,9 +1,8 @@
|
||||
package com.uam.wmi.findmytutor.service;
|
||||
import com.uam.wmi.findmytutor.model.PredefinedCoordViewModel;
|
||||
import com.uam.wmi.findmytutor.model.StatusesListModel;
|
||||
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;
|
||||
@ -16,9 +15,8 @@ public interface PredefinedStatusesService {
|
||||
@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)
|
||||
Single<List<String>> deleteUserPredefinedStatus(@Path("tutorId") String tutorId, @Body String status);
|
||||
Single<List<String>> deleteUserPredefinedStatus(@Path("tutorId") String tutorId, @Body StatusesListModel statusesLis);
|
||||
|
||||
/* @GET("api/users/predefined/coordinate/{tutorId}")
|
||||
Single<List<PredefinedCoordViewModel>> getUserPredefinedCoords(@Path("tutorId") String tutorId);
|
||||
|
@ -0,0 +1,35 @@
|
||||
package com.uam.wmi.findmytutor.service;
|
||||
|
||||
|
||||
import com.uam.wmi.findmytutor.model.IsUsingListBool;
|
||||
import com.uam.wmi.findmytutor.model.StudentIdModel;
|
||||
import com.uam.wmi.findmytutor.model.User;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.Completable;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.Single;
|
||||
import retrofit2.http.Body;
|
||||
import retrofit2.http.DELETE;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.POST;
|
||||
import retrofit2.http.PUT;
|
||||
import retrofit2.http.Path;
|
||||
|
||||
public interface WhiteListService {
|
||||
@GET("api/users/{id}")
|
||||
Single<User> getUserById(@Path("id") String userID);
|
||||
|
||||
@GET("api/users/whitelist/{tutorId}")
|
||||
Single<List<String>> getTutorWhitelist(@Path("tutorId") String tutorID);
|
||||
|
||||
@PUT("api/users/whitelist/{tutorId}")
|
||||
Completable setTutorWhitelist(@Path("tutorId") String tutorID, @Body IsUsingListBool isUsing);
|
||||
|
||||
@POST("api/users/whitelist/{tutorId}")
|
||||
Observable<User> addStudentToWhitelist(@Path("tutorId") String tutorID, @Body StudentIdModel student);
|
||||
|
||||
@DELETE("api/users/whitelist/{tutorId}")
|
||||
Completable removeStudentFromWhitelist(@Path("tutorId") String tutorID, @Body StudentIdModel student);
|
||||
}
|
@ -21,6 +21,12 @@ public class Const {
|
||||
public final static Range<Double> outsideLongitudeRange = Range.create(16.9186, 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";
|
||||
|
||||
public final static int maxPredefinedCordNameLength = 25;
|
||||
public final static int maxStatusLength = 25;
|
||||
public final static int maxDayLength = 20;
|
||||
public final static int maxNoteLength = 100;
|
||||
public final static int maxRoomLength = 10;
|
||||
}
|
||||
|
||||
|
||||
|
@ -0,0 +1,37 @@
|
||||
package com.uam.wmi.findmytutor.utils;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.app.DialogFragment;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.uam.wmi.findmytutor.R;
|
||||
import com.uam.wmi.findmytutor.activity.MapActivity;
|
||||
|
||||
import static com.uam.wmi.findmytutor.utils.PrefUtils.storeBackgroundLocationStatus;
|
||||
|
||||
public class EnableLocalization extends DialogFragment {
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
|
||||
return new AlertDialog.Builder(getActivity())
|
||||
.setTitle(R.string.enable_sharing)
|
||||
.setMessage(R.string.use_gps)
|
||||
.setPositiveButton(R.string.possitive_dialog_button, (dialog, which) ->
|
||||
dialogPositiveAnswer(getActivity())
|
||||
)
|
||||
.setNegativeButton(R.string.negative_dialog_button, (dialog, which) -> {
|
||||
PrefUtils.storeEnableSharingLocalization(getActivity(), false);
|
||||
dialog.cancel();
|
||||
}).create();
|
||||
}
|
||||
|
||||
private void dialogPositiveAnswer(Context context) {
|
||||
startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));
|
||||
}
|
||||
}
|
@ -244,7 +244,7 @@ public class PrefUtils {
|
||||
}
|
||||
|
||||
public static Boolean shouldBatteryExclusionBeShown(Context context) {
|
||||
return getSharedPreferences(context).getBoolean("show_battery_exclusion", false);
|
||||
return getSharedPreferences(context).getBoolean("show_battery_exclusion", true);
|
||||
}
|
||||
|
||||
public static void setBatteryExlusionInfoStatus(Context context, Boolean flag) {
|
||||
|
@ -17,7 +17,7 @@ public class WifiUtils {
|
||||
if (wifiInfo != null) {
|
||||
NetworkInfo.DetailedState state = WifiInfo.getDetailedStateOf(wifiInfo.getSupplicantState());
|
||||
if (state == NetworkInfo.DetailedState.CONNECTED || state == NetworkInfo.DetailedState.OBTAINING_IPADDR) {
|
||||
return wifiInfo.getSSID();
|
||||
return wifiInfo.getSSID().replace("\"", "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<AutoCompleteTextView
|
||||
<android.support.design.widget.TextInputEditText
|
||||
android:id="@+id/email"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@ -61,7 +61,7 @@
|
||||
app:passwordToggleEnabled="true"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<EditText
|
||||
<android.support.design.widget.TextInputEditText
|
||||
android:id="@+id/password"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -168,7 +168,7 @@
|
||||
android:layout_marginEnd="30dp"
|
||||
android:layout_marginTop="15dp"
|
||||
app:counterEnabled="true"
|
||||
app:counterMaxLength="1000">
|
||||
app:counterMaxLength="100">
|
||||
|
||||
<android.support.design.widget.TextInputEditText
|
||||
android:id="@+id/userNote"
|
||||
@ -178,7 +178,7 @@
|
||||
android:hint="@string/tutorTabHint"
|
||||
android:inputType="textMultiLine"
|
||||
android:lineSpacingExtra="8sp"
|
||||
android:maxLength="1000"
|
||||
android:maxLength="100"
|
||||
android:maxLines="7"
|
||||
android:paddingTop="15dp"
|
||||
android:requiresFadingEdge="vertical"
|
||||
|
@ -10,28 +10,14 @@
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/feedback_modal_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignStart="@+id/feedback_input"
|
||||
android:layout_marginBottom="@dimen/dimen_10"
|
||||
android:fontFamily="sans-serif-medium"
|
||||
android:lineSpacingExtra="8sp"
|
||||
android:text="@string/manual_modal_title"
|
||||
android:textColor="@color/colorAccent"
|
||||
android:textSize="@dimen/lbl_new_note_title"
|
||||
android:textStyle="normal" />
|
||||
|
||||
<EditText
|
||||
<EditText
|
||||
android:id="@+id/manual_input"
|
||||
android:layout_width="315dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="50dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:ems="10"
|
||||
android:hint="@string/modal_manual_hint"
|
||||
android:maxLength="30"
|
||||
android:maxLines="1"
|
||||
android:requiresFadingEdge="vertical"
|
||||
|
@ -131,6 +131,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:autoLink="web|email"
|
||||
android:paddingLeft="10dp"
|
||||
android:textColor="@color/mapboxWhite" />
|
||||
</LinearLayout>
|
||||
|
@ -146,13 +146,13 @@
|
||||
<string name="modal_feedback_thankyou">Dziękujemy za przesłanie feedbacku.</string>
|
||||
<string name="remove_manual_location">Usuń manualną lokację</string>
|
||||
<string name="title_activity_tutor_tab">Profil</string>
|
||||
<string name="saveButton">Zapisz!</string>
|
||||
<string name="saveButton">Zapisz</string>
|
||||
<string name="tutorTabHint">Edytuj swoją notatkę. Będzie widoczna dla innych.</string>
|
||||
<string name="modal_location_send">WYŚLIJ</string>
|
||||
<string name="modal_location_hint">Proszę nazwać wybraną lokację.</string>
|
||||
<string name="manual_modal_title">Czy chcesz zapisać tę lokalizację?</string>
|
||||
<string name="lbl_ok">Zapisz!</string>
|
||||
<string name="lbl_cancel">Zakończ!</string>
|
||||
<string name="lbl_ok">Zapisz</string>
|
||||
<string name="lbl_cancel">Zakończ</string>
|
||||
<string name="manual_marker_info">Twój marker zniknie w ciągu kilku minut.</string>
|
||||
<string name="manual_location_selected">Lokalizacja manualna wybrana!</string>
|
||||
<string name="location_saved">Lokacja zapisana!</string>
|
||||
@ -289,10 +289,23 @@
|
||||
<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="no_tutor_tab">Zakładka użytkownika nie istnieje</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>
|
||||
|
||||
<!--(ENG) ask for gps -->
|
||||
<string name="enable_sharing">Włącz lokalizację</string>
|
||||
<string name="use_gps">Aby użyć tej funkcji musisz włączyć lokalizowanie urządzenia.</string>
|
||||
<string name="delete">USUŃ</string>
|
||||
<string name="status_max_length">Maksymalna długość statusu</string>
|
||||
<string name="max_note_length_error">Maksymalna długość notatki</string>
|
||||
<string name="max_day_length_error">Maksymalna długość pola dzień</string>
|
||||
<string name="max_room_lenth_error">Maksymalna długość pola pokój</string>
|
||||
<string name="manual_location_tolong_error">Maksymalna długość nazwy lokalizacji</string>
|
||||
<string name="end_b4_start_error">Data końcowa wcześniej niż początkowa</string>
|
||||
|
||||
<!--(ENG) Modal ans -->
|
||||
<string name="lbl_yes">Tak</string>
|
||||
<string name="lbl_no">Nie</string>
|
||||
</resources>
|
||||
|
||||
|
@ -222,7 +222,7 @@
|
||||
<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="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>
|
||||
@ -458,5 +458,23 @@
|
||||
<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="no_tutor_tab">Tutor tab not found for this user</string>
|
||||
<string name="never_logged_in">Never</string>
|
||||
|
||||
<!--(ENG) ask for gps -->
|
||||
<string name="enable_sharing">Enable localization</string>
|
||||
<string name="use_gps">In order to use this function you have to enable localization.</string>
|
||||
<string name="delete">DELETE</string>
|
||||
<string name="status_max_length">Status max length</string>
|
||||
<string name="end_b4_start_error">End hour before start</string>
|
||||
<string name="max_day_length_error">Max day length</string>
|
||||
<string name="max_note_length_error">Max note length</string>
|
||||
<string name="max_room_lenth_error">Max room length</string>
|
||||
<string name="manual_location_tolong_error">Max manual location name</string>
|
||||
|
||||
|
||||
<!--(ENG) Modal ans -->
|
||||
<string name="lbl_yes">Yes</string>
|
||||
<string name="lbl_no">No</string>
|
||||
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user