Merge user list to develop #24

Merged
s416204 merged 25 commits from tutors-list-activity into develop 2018-11-02 18:00:23 +01:00
29 changed files with 670 additions and 260 deletions

View File

@ -38,6 +38,10 @@
android:launchMode="singleTask"
android:noHistory="true" />
<activity
android:name=".activity.SettingsActivity"
android:label="@string/title_activity_settings" />
<service
android:name=".service.BackgroundLocalizationService"
android:exported="false"

View File

@ -2,33 +2,47 @@ package com.uam.wmi.findmytutor.activity;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomNavigationView;
import android.support.design.widget.NavigationView;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.FrameLayout;
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.PrefUtils;
public abstract class BaseActivity
extends AppCompatActivity
implements BottomNavigationView.OnNavigationItemSelectedListener {
protected BottomNavigationView navigationView;
protected Toolbar toolbar;
protected static final int REQUEST_PERMISSIONS = 100;
public DrawerLayout drawerLayout;
protected BottomNavigationView navigationView;
protected NavigationView drawerNavigationView;
protected DrawerLayout sideDrawer;
protected Toolbar toolbar;
protected boolean isTutor;
boolean boolean_permission;
private ActionBarDrawerToggle actionBarDrawerToggle;
private SharingFragment sharingFragment;
private Fragment userListFragment;
private ActiveFragment activeFragment = ActiveFragment.NONE;
@ -37,11 +51,55 @@ public abstract class BaseActivity
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(getContentViewId());
drawerNavigationView = findViewById(R.id.nav_view);
sideDrawer = findViewById(R.id.activity_container);
drawerNavigationView.setNavigationItemSelectedListener(
new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
String itemName = (String) item.getTitle();
Intent launchIntent;
if (itemName.equals("Whitelist")) {
/* launchIntent = new Intent(getApplicationContext(), WhitelistActivity.class);
startActivity(launchIntent);*/
} else if (itemName.equals("Blacklist")) {
/* launchIntent = new Intent(getApplicationContext(), BlacklistActivity.class);
startActivity(launchIntent);*/
} else if (itemName.equals("Profile")) {
/* launchIntent = new Intent(getApplicationContext(), ProfileActivity.class);
startActivity(launchIntent);*/
} else if (itemName.equals("Settings")) {
launchIntent = new Intent(getApplicationContext(), SettingsActivity.class);
startActivity(launchIntent);
} else if (itemName.equals("Log out")) {
PrefUtils.cleanUserLocalStorage(getApplicationContext());
Intent i = getBaseContext().getPackageManager()
.getLaunchIntentForPackage(getBaseContext().getPackageName());
if (i != null) {
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
}
startActivity(i);
finish();
}
sideDrawer.closeDrawers();
return true;
}
}
);
navigationView = findViewById(R.id.navigation);
navigationView.setOnNavigationItemSelectedListener(this);
sharingFragment = new SharingFragment();
userListFragment = new UsersListActivity();
userListFragment = new UsersListFragment();
isTutor = PrefUtils.getIsTutor(getApplicationContext());
if (!isTutor) {
navigationView.findViewById(R.id.nav_profile).setVisibility(View.GONE);
}
}
@Override
@ -81,6 +139,38 @@ public abstract class BaseActivity
setUpNav();
actionBarDrawerToggle.syncState();
if (isTutor) {
fn_permission();
}
}
private void fn_permission() {
if ((ContextCompat.checkSelfPermission(getApplicationContext(), android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED)) {
if ((ActivityCompat.shouldShowRequestPermissionRationale(BaseActivity.this, android.Manifest.permission.ACCESS_FINE_LOCATION))) {
} else {
ActivityCompat.requestPermissions(BaseActivity.this, new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION
},
REQUEST_PERMISSIONS);
}
} else {
if (isTutor) {
Intent intent = new Intent(getApplicationContext(), BackgroundLocalizationService.class);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
startForegroundService(intent);
} else {
startService(intent);
}
} else {
Toast.makeText(getApplicationContext(), "Please enable the gps", Toast.LENGTH_SHORT).show();
}
}
}
@Override
@ -90,15 +180,15 @@ public abstract class BaseActivity
}
@Override
public boolean onCreateOptionsMenu( Menu menu) {
getMenuInflater().inflate( R.menu.menu_main, menu);
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
MenuItem myActionMenuItem = menu.findItem(R.id.action_search);
final SearchView searchView = (SearchView) myActionMenuItem.getActionView();
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String input) {
if(activeFragment.equals(ActiveFragment.USER_LIST)){
if (activeFragment.equals(ActiveFragment.USER_LIST)) {
executeUserListSearch(input);
}
@ -106,20 +196,22 @@ public abstract class BaseActivity
}
@Override
public boolean onQueryTextChange(String input) {
if(activeFragment.equals(ActiveFragment.USER_LIST)){
if (activeFragment.equals(ActiveFragment.USER_LIST)) {
executeUserListSearch(input);
}
return true;
}
});
return true;
}
private void executeUserListSearch(String input){
((UsersListActivity) userListFragment).searchUser(input);
private void executeUserListSearch(String input) {
((UsersListFragment) userListFragment).searchUser(input);
}
@Override
@ -130,6 +222,21 @@ public abstract class BaseActivity
return super.onOptionsItemSelected(item);
}
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
switch (requestCode) {
case REQUEST_PERMISSIONS: {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
boolean_permission = true;
} else {
Toast.makeText(getApplicationContext(), "Please allow the permission", Toast.LENGTH_LONG).show();
}
}
}
}
@Override
protected void onStart() {
super.onStart();
@ -139,7 +246,7 @@ public abstract class BaseActivity
@Override
public void onPause() {
super.onPause();
overridePendingTransition(0,0);
overridePendingTransition(0, 0);
}
private void removeFragment(Fragment fragment) {
@ -179,7 +286,7 @@ public abstract class BaseActivity
private void loadUserListFragment() {
activeFragment = ActiveFragment.USER_LIST;
userListFragment = UsersListActivity.newInstance();
userListFragment = UsersListFragment.newInstance();
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.replace(R.id.activity_content, userListFragment);
ft.commit();

View File

@ -10,12 +10,13 @@ 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 android.widget.ProgressBar;
import android.widget.Switch;
import com.auth0.android.jwt.Claim;
@ -25,6 +26,7 @@ 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;
@ -142,6 +144,7 @@ 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() {
@ -159,12 +162,20 @@ public class LoginActivity extends AppCompatActivity {
mProgressView.setVisibility(show ? View.VISIBLE : View.GONE);
}
});
}
private void loginProcess(String email, String password) {
//Fake validate
LdapUser user = new LdapUser(email, password, "admin", (isTutor) ? "Tutor" : "Student", "string", "string", email);
// ValidateUser user = new ValidateUser(email, password);
// LDAP logging
// disposable.add(ldapService.validate(user)
disposable.add(ldapService.fakeValidate(user)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
@ -172,9 +183,8 @@ public class LoginActivity extends AppCompatActivity {
}
private void getUserProfile(String userId) {
disposable.add(
userService
.getUserByID(userId)
disposable.add(userService.getUserByID(userId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(this::saveUserProfileToSharedPreferences, this::handleError));
@ -192,6 +202,7 @@ public class LoginActivity extends AppCompatActivity {
JWT jwt = new JWT(token);
Claim role = jwt.getClaim("nameid");
PrefUtils.storeIsLoggedIn(getApplicationContext(), true);
PrefUtils.storeApiKey(getApplicationContext(), token);
PrefUtils.storeUserId(getApplicationContext(), role.asString());
@ -223,5 +234,6 @@ public class LoginActivity extends AppCompatActivity {
PrefUtils.storeUserLastName(getApplicationContext(), user.getLastName());
PrefUtils.storeUserName(getApplicationContext(), user.getUserName());
}
}

View File

@ -1,35 +1,197 @@
package com.uam.wmi.findmytutor.activity;
import android.animation.ObjectAnimator;
import android.animation.TypeEvaluator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.widget.Toast;
import android.os.Handler;
import android.util.Log;
import com.mapbox.mapboxsdk.Mapbox;
import com.mapbox.mapboxsdk.annotations.Marker;
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
import com.mapbox.mapboxsdk.annotations.MarkerViewOptions;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.uam.wmi.findmytutor.R;
import com.uam.wmi.findmytutor.model.Coordinate;
import com.uam.wmi.findmytutor.network.ApiClient;
import com.uam.wmi.findmytutor.network.RetrofitClientInstance;
import com.uam.wmi.findmytutor.service.BackgroundLocalizationService;
import com.uam.wmi.findmytutor.service.CoordinateService;
import com.uam.wmi.findmytutor.utils.PrefUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.observers.DisposableSingleObserver;
import io.reactivex.schedulers.Schedulers;
public class MapActivity extends BaseActivity
implements OnMapReadyCallback {
public class MapActivity extends BaseActivity {
private MapView mapView;
String tag = "LifeCycleEvents";
private MapView mapView;
private MapboxMap mapboxMap;
private int mInterval = 10000;
private Handler mHandler;
private Map<String,Coordinate> coordsMap = new HashMap<>();
private CoordinateService coordinateService;
private CompositeDisposable disposable = new CompositeDisposable();
private Runnable mStatusChecker;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Mapbox.getInstance(this, getString(R.string.access_token));
mapView = findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(new OnMapReadyCallback() {
final SharedPreferences sharedPref = getSharedPreferences("fmtPrefs", Context.MODE_PRIVATE);
final String authToken = sharedPref.getString("authToken",null);
mStatusChecker = new Runnable() {
@Override
public void onMapReady(MapboxMap mapboxMap) {
public void run() {
try{
fetchTopCoords();
} finally {
mHandler.postDelayed(mStatusChecker, mInterval);
}
}
};
// Customize map with markers, polylines, etc.
// fetching coords service
coordinateService = ApiClient.getClient(getApplicationContext())
.create(CoordinateService.class);
mHandler = new Handler();
Bundle extras = getIntent().getExtras();
Mapbox.getInstance(this, getString(R.string.access_token));
mapView = (MapView) findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(this);
}
@Override
public void onMapReady(MapboxMap map) {
mapboxMap = map;
final Marker marker = mapboxMap.addMarker(new MarkerViewOptions()
.position(new LatLng(52.466782,16.927549)));
mStatusChecker.run();
mapboxMap.addOnMapClickListener(new MapboxMap.OnMapClickListener() {
@Override
public void onMapClick(@NonNull LatLng point) {
// When the user clicks on the map, we want to animate the marker to that
// location.
ValueAnimator markerAnimator = ObjectAnimator.ofObject(marker, "position",
new LatLngEvaluator(), marker.getPosition(), point);
markerAnimator.setDuration(2000);
markerAnimator.start();
}
});
}
private static class LatLngEvaluator implements TypeEvaluator<LatLng> {
// Method is used to interpolate the marker animation.
private LatLng latLng = new LatLng();
@Override
public LatLng evaluate(float fraction, LatLng startValue, LatLng endValue) {
latLng.setLatitude(startValue.getLatitude()
+ ((endValue.getLatitude() - startValue.getLatitude()) * fraction));
latLng.setLongitude(startValue.getLongitude()
+ ((endValue.getLongitude() - startValue.getLongitude()) * fraction));
return latLng;
}
}
private void fetchTopCoords() {
disposable.add(
// coordinateService.getTopCoordinates()
coordinateService.getOnlineCoordinates()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribeWith(new DisposableSingleObserver<List<Coordinate>>() {
@Override
public void onSuccess(List<Coordinate> coordsList) {
for (Coordinate element : coordsList) {
String id = element.getUserId();
Coordinate cord = coordsMap.get(id);
Log.d("mapper", "a " + mapboxMap.getMarkerViewManager());
Log.d("mapper", "b " + coordsMap.size());
if (cord != null) {
if (!cord.getLongitude().equals(element.getLongitude())
) {
Log.d("mapper", " cos sie zienilo ");
Marker marker = mapboxMap.addMarker(new MarkerViewOptions()
.title(cord.getUserId())
.position(new LatLng(cord.getLatitude(),cord.getLongitude())));
ValueAnimator markerAnimator = ObjectAnimator.ofObject(marker, "position",
new LatLngEvaluator(), marker.getPosition(), new LatLng(element.getLatitude(),element.getLongitude()));
markerAnimator.setDuration(2000);
markerAnimator.start();
// coordsMap.replace(id,element);
coordsMap.remove(id);
coordsMap.put(id,element);
} else if (!cord.getTimeStamp().equals(element.getTimeStamp())){
Log.d("mapper", "update");
Log.d("mapper", " "+cord.getTimeStamp());
Log.d("mapper", " " + element.getTimeStamp());
// coordsMap.replace(id,element);
coordsMap.remove(id);
coordsMap.put(id,element);
}
} else {
coordsMap.put(id,element);
mapboxMap.addMarker(new MarkerOptions().position(new LatLng(element.getLatitude(), element.getLongitude())));
}
}
}
@Override
public void onError(Throwable e) {
Log.e("Error",e.toString());
}
})
);
}
// Add the mapView lifecycle to the activity's lifecycle methods
@ -67,6 +229,8 @@ public class MapActivity extends BaseActivity {
protected void onDestroy() {
super.onDestroy();
mapView.onDestroy();
mHandler.removeCallbacks(mStatusChecker);
disposable.dispose();
}
@Override
@ -75,6 +239,34 @@ public class MapActivity extends BaseActivity {
mapView.onSaveInstanceState(outState);
}
private void fn_permission() {
if ((ContextCompat.checkSelfPermission(getApplicationContext(), android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED)) {
if ((ActivityCompat.shouldShowRequestPermissionRationale(MapActivity.this, android.Manifest.permission.ACCESS_FINE_LOCATION))) {
} else {
ActivityCompat.requestPermissions(MapActivity.this, new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION
},
REQUEST_PERMISSIONS);
}
} else {
if (isTutor) {
Intent intent = new Intent(getApplicationContext(), BackgroundLocalizationService.class);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
startForegroundService(intent);
} else {
startService(intent);
}
} else {
Toast.makeText(getApplicationContext(), "Please enable the gps", Toast.LENGTH_SHORT).show();
}
}
}
@Override
protected int getContentViewId() {
return R.layout.activity_map;

View File

@ -1,31 +0,0 @@
package com.uam.wmi.findmytutor.activity;
import android.os.Bundle;
import android.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.uam.wmi.findmytutor.R;
/**
* A simple {@link Fragment} subclass.
*/
public class NotificationFragment extends Fragment {
public NotificationFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_notification, container, false);
}
}

View File

@ -1,31 +0,0 @@
package com.uam.wmi.findmytutor.activity;
import android.os.Bundle;
import android.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.uam.wmi.findmytutor.R;
/**
* A simple {@link Fragment} subclass.
*/
public class ProfileFragment extends Fragment {
public ProfileFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_profile, container, false);
}
}

View File

@ -0,0 +1,110 @@
package com.uam.wmi.findmytutor.activity;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.preference.EditTextPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
import android.view.MenuItem;
import com.uam.wmi.findmytutor.R;
public class SettingsActivity extends AppCompatPreferenceActivity {
private static final String TAG = SettingsActivity.class.getSimpleName();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// load settings fragment
getFragmentManager().beginTransaction().replace(android.R.id.content, new MainPreferenceFragment()).commit();
}
public static class MainPreferenceFragment extends PreferenceFragment {
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.layout.pref_main);
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) {
onBackPressed();
}
return super.onOptionsItemSelected(item);
}
private static void bindPreferenceSummaryToValue(Preference preference) {
preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener);
sBindPreferenceSummaryToValueListener.onPreferenceChange(preference,
PreferenceManager
.getDefaultSharedPreferences(preference.getContext())
.getString(preference.getKey(), ""));
}
/**
* A preference value change listener that updates the preference's summary
* to reflect its new value.
*/
private static Preference.OnPreferenceChangeListener sBindPreferenceSummaryToValueListener = new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
String stringValue = newValue.toString();
if (preference instanceof ListPreference) {
// For list preferences, look up the correct display value in
// the preference's 'entries' list.
ListPreference listPreference = (ListPreference) preference;
int index = listPreference.findIndexOfValue(stringValue);
// Set the summary to reflect the new value.
preference.setSummary(
index >= 0
? listPreference.getEntries()[index]
: null);
} else if (preference instanceof EditTextPreference) {
if (preference.getKey().equals("key_gallery_name")) {
// update the changed gallery name to summary filed
preference.setSummary(stringValue);
}
} else {
preference.setSummary(stringValue);
}
return true;
}
};
/**
* Email client intent to send support mail
* Appends the necessary device information to email body
* useful when providing support
*/
public static void sendFeedback(Context context) {
String body = null;
try {
body = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
body = "\n\n-----------------------------\nPlease don't remove this information\n Device OS: Android \n Device OS version: " +
Build.VERSION.RELEASE + "\n App Version: " + body + "\n Device Brand: " + Build.BRAND +
"\n Device Model: " + Build.MODEL + "\n Device Manufacturer: " + Build.MANUFACTURER;
} catch (PackageManager.NameNotFoundException e) {
}
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("message/rfc822");
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"team@findmytutor.com"});
intent.putExtra(Intent.EXTRA_SUBJECT, "Query from android app");
intent.putExtra(Intent.EXTRA_TEXT, body);
context.startActivity(Intent.createChooser(intent, context.getString(R.string.choose_email_client)));
}
}

View File

@ -19,7 +19,8 @@ import android.widget.TextView;
import com.annimon.stream.Stream;
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
import com.uam.wmi.findmytutor.R;
import com.uam.wmi.findmytutor.adapters.TutorsAdapter;
import com.uam.wmi.findmytutor.adapters.TutorsListAdapter;
import com.uam.wmi.findmytutor.model.DutyHourViewModel;
import com.uam.wmi.findmytutor.model.TutorTabViewModel;
import com.uam.wmi.findmytutor.model.User;
@ -44,8 +45,8 @@ import okhttp3.ResponseBody;
import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext;
public class UsersListActivity extends Fragment {
private static final String TAG = UsersListActivity.class.getSimpleName();
public class UsersListFragment extends Fragment {
private static final String TAG = UsersListFragment.class.getSimpleName();
@BindView(R.id.coordinator_layout)
CoordinatorLayout coordinatorLayout;
@ -57,19 +58,19 @@ public class UsersListActivity extends Fragment {
private UserService userService;
private TutorTabApi tutorTabService;
private CompositeDisposable disposable = new CompositeDisposable();
private TutorsAdapter mAdapter;
private TutorsListAdapter mAdapter;
private List<User> tutorsList = new ArrayList<>();
private List<User> tutorsFiltered = new ArrayList<>();
public UsersListActivity() {
public UsersListFragment() {
}
public static UsersListActivity newInstance() {
return new UsersListActivity();
public static UsersListFragment newInstance() {
return new UsersListFragment();
}
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mAdapter = new TutorsAdapter(getActivity().getApplicationContext(), tutorsFiltered);
mAdapter = new TutorsListAdapter(getActivity().getApplicationContext(), tutorsFiltered);
View view = inflater.inflate(R.layout.users_list, container, false);
view.setBackgroundColor(getResources().getColor(android.R.color.white));
return view;

View File

@ -2,6 +2,7 @@ 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.util.Log;
import android.view.LayoutInflater;
@ -18,21 +19,18 @@ import butterknife.BindView;
import butterknife.ButterKnife;
public class TutorsAdapter extends RecyclerView.Adapter<TutorsAdapter.MyViewHolder> {
public class TutorsListAdapter extends RecyclerView.Adapter<TutorsListAdapter.MyViewHolder> {
private Context context;
private List<User> tutorsList;
public TutorsAdapter(Context context, List<User> tutors) {
public TutorsListAdapter(Context context, List<User> tutors) {
this.context = context;
this.tutorsList = tutors;
Log.e("USERS", String.valueOf(tutors));
}
public class MyViewHolder extends RecyclerView.ViewHolder {
class MyViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.firstName)
TextView firstName;
@ -43,16 +41,15 @@ public class TutorsAdapter extends RecyclerView.Adapter<TutorsAdapter.MyViewHold
@BindView(R.id.isOnline)
TextView isOnline;
public MyViewHolder(View view) {
MyViewHolder(View view) {
super(view);
ButterKnife.bind(this, view);
}
}
@NonNull
@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.tutor_list_row, parent, false);
@ -60,28 +57,25 @@ public class TutorsAdapter extends RecyclerView.Adapter<TutorsAdapter.MyViewHold
}
@Override
public void onBindViewHolder(MyViewHolder holder, int position) {
public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
Drawable image = null;
User tutor = tutorsList.get(position);
holder.firstName.setText(tutor.getFirstName());
holder.lastName.setText(tutor.getLastName());
if(tutor.isIsOnline()) {
Drawable image = context.getResources().getDrawable(R.drawable.online_user);
image.setBounds(0, 0, image.getIntrinsicWidth(), image.getIntrinsicHeight());
holder.isOnline.setCompoundDrawables(image, null, null, null);
image = context.getResources().getDrawable(R.drawable.online_user);
} else {
Drawable image = context.getResources().getDrawable(R.drawable.not_online);
image.setBounds(0, 0, image.getIntrinsicWidth(), image.getIntrinsicHeight());
holder.isOnline.setCompoundDrawables(image, null, null, null);
image = context.getResources().getDrawable(R.drawable.not_online);
}
if(!tutor.isIsActive()){
Drawable image = context.getResources().getDrawable(R.drawable.not_active_user);
image.setBounds(0, 0, image.getIntrinsicWidth(), image.getIntrinsicHeight());
holder.isOnline.setCompoundDrawables(image, null, null, null);
image = context.getResources().getDrawable(R.drawable.not_active_user);
}
image.setBounds(0, 0, image.getIntrinsicWidth(), image.getIntrinsicHeight());
holder.isOnline.setCompoundDrawables(image, null, null, null);
}
@Override

View File

@ -198,7 +198,7 @@ public class LdapUser extends BaseResponse {
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class LdapUser {\n");
sb.append(" login: ").append(toIndentedString(login)).append("\n");
sb.append(" password: ").append(toIndentedString(password)).append("\n");
sb.append(" department: ").append(toIndentedString(department)).append("\n");

View File

@ -0,0 +1,94 @@
package com.uam.wmi.findmytutor.model;
import com.google.gson.annotations.SerializedName;
import java.util.Objects;
import io.swagger.annotations.ApiModelProperty;
/**
* ValidateUser
*/
public class ValidateUser extends BaseResponse {
@SerializedName("login")
private String login = null;
@SerializedName("password")
private String password = null;;
public ValidateUser(String login, String password) {
this.login = login;
this.password = password;
}
public ValidateUser login(String login) {
this.login = login;
return this;
}
/**
* Get login
* @return login
**/
@ApiModelProperty(required = true, value = "")
public String getLogin() {
return login;
}
public void setLogin(String login) {
this.login = login;
}
public ValidateUser password(String password) {
this.password = password;
return this;
}
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ValidateUser ValidateUser = (ValidateUser) o;
return Objects.equals(this.login, ValidateUser.login) &&
Objects.equals(this.password, ValidateUser.password);
}
@Override
public int hashCode() {
return Objects.hash(login, password);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class ValidateUser {\n");
sb.append(" login: ").append(toIndentedString(login)).append("\n");
sb.append(" password: ").append(toIndentedString(password)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -2,6 +2,7 @@ package com.uam.wmi.findmytutor.service;
import com.uam.wmi.findmytutor.model.JwtToken;
import com.uam.wmi.findmytutor.model.LdapUser;
import com.uam.wmi.findmytutor.model.ValidateUser;
import io.reactivex.Single;
import retrofit2.http.Body;
@ -15,7 +16,7 @@ public interface LdapService {
Single<JwtToken> fakeValidate(@Body LdapUser user);
@POST("api/ldap/validate")
Single<JwtToken> validate(@Body LdapUser user);
Single<JwtToken> validate(@Body ValidateUser user);
@GET("api/ldap/getUserData/{login}")
Single<LdapUser> getUserDataByLogin(@Path("login") String userLogin);

View File

@ -0,0 +1,49 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="68dp"
android:height="68dp"
android:viewportWidth="68"
android:viewportHeight="68">
<path
android:pathData="M56.3,44.2c-2.1,2.2 -4.6,3.9 -7.3,5.2c-1.5,0.7 -29,8.5 -40.7,11.8c-1,0.3 -1.9,0.5 -2.6,0.7c0.2,-0.7 0.4,-1.6 0.7,-2.6c2.9,-11.6 9.9,-38.9 10.5,-40.4c1.2,-2.7 2.9,-5.1 5,-7.3c9.1,-9.3 23.8,-10.2 33.7,-2.5c0.4,0.3 0.7,0.6 1.1,0.9c0.3,0.3 0.6,0.6 0.9,1C65.8,20.5 65.4,34.9 56.3,44.2z"
android:strokeWidth="3"
android:fillColor="#00000000"
android:strokeColor="#000000"/>
<path
android:pathData="M46.7,48.1"
android:strokeWidth="3"
android:fillColor="#00000000"
android:strokeColor="#000000"/>
<path
android:fillColor="#FF000000"
android:pathData="M24.8,29.7l1,1.8l3.5,-2l1.5,2.7l-3.5,2l2.2,3.9l-3.1,1.7l-6.2,-11l7,-4l1.6,2.7L24.8,29.7z"/>
<path
android:fillColor="#FF000000"
android:pathData="M28,22.9l1.4,2.5l2.9,-1.6l-1.4,-2.5L28,22.9zM30,26.5l4.8,8.5l1.2,-4.8l-3,-5.4L30,26.5z"/>
<path
android:fillColor="#FF000000"
android:pathData="M45,22.4l2.9,5.2L45,29.2l-2.7,-4.8c-0.6,-1 -1.2,-1.3 -1.9,-0.9c-0.9,0.5 -1.1,1.5 -0.5,2.5l2.6,4.5l-2.9,1.7l-4.8,-8.5l2.1,-1.2l0.9,0.6c0.2,-1.1 0.9,-2 2,-2.6C41.7,19.5 43.8,20.2 45,22.4z"/>
<path
android:fillColor="#FF000000"
android:pathData="M52.1,9.9l6.6,11.6l-2.2,1.2l-0.6,-0.5c-0.4,1 -1.1,1.8 -2,2.4c-2.6,1.5 -5.5,0.6 -7,-2c-1.5,-2.6 -0.7,-5.6 1.9,-7.1c0.8,-0.4 1.6,-0.6 2.4,-0.6l-1.9,-3.4L52.1,9.9zM53.6,18.8c-0.6,-1.1 -1.9,-1.5 -3,-0.9c-1.1,0.6 -1.4,1.9 -0.8,3c0.6,1.1 1.9,1.5 3,0.9S54.2,19.9 53.6,18.8z"/>
<path
android:fillColor="#FF000000"
android:pathData="M24.1,42.1l-3,1.7l4.7,8.3l-3,1.7L18,45.5l-3,1.7l-1.5,-2.7l9,-5.1L24.1,42.1z"/>
<path
android:fillColor="#FF000000"
android:pathData="M27.2,46.4l-2.7,-4.8l2.9,-1.7l2.7,4.7c0.5,0.9 1.3,1.2 2.1,0.7c0.8,-0.4 1,-1.2 0.4,-2.1l-2.7,-4.7l2.9,-1.7l2.7,4.8c1.3,2.4 0.6,4.9 -2,6.3C31.1,49.4 28.6,48.8 27.2,46.4z"/>
<path
android:fillColor="#FF000000"
android:pathData="M43.7,38.5l1.5,2.6l-2,1.1c-1.9,1.1 -3.7,0.6 -4.7,-1.3l-1.8,-3.2L35,38.6l-0.4,-0.7l1.5,-6.2l0.6,-0.3l1.4,2.5l2.1,-1.2l1.3,2.3l-2.1,1.2l1.5,2.7c0.3,0.6 0.9,0.8 1.5,0.4L43.7,38.5z"/>
<path
android:fillColor="#FF000000"
android:pathData="M43.6,36.4c-1.5,-2.6 -0.6,-5.7 2.2,-7.2c2.8,-1.6 5.8,-0.8 7.3,1.8c1.5,2.6 0.6,5.7 -2.2,7.2C48.1,39.8 45,39 43.6,36.4zM49.4,35.6c1.1,-0.6 1.4,-1.8 0.8,-2.9c-0.6,-1.1 -1.8,-1.5 -2.9,-0.9s-1.4,1.8 -0.8,2.9C47.1,35.8 48.3,36.2 49.4,35.6L49.4,35.6z"/>
<path
android:fillColor="#FF000000"
android:pathData="M57.5,22.8l1.5,2.7l-1.1,0.6c-1,0.6 -1.2,1.3 -0.6,2.4l2.4,4.3l-2.9,1.7L52,26l2,-1.1l1,0.7c0.2,-1 0.8,-1.7 1.8,-2.3L57.5,22.8z"/>
<path
android:fillColor="#FF000000"
android:pathData="M20.8,37.8l0.9,1.7L20.8,40L20,38.5c-0.2,-0.3 -0.3,-0.4 -0.5,-0.2c-0.3,0.1 -0.3,0.4 -0.1,0.7l0.8,1.5l-0.9,0.5l-0.9,-1.6c-0.2,-0.3 -0.3,-0.4 -0.5,-0.2c-0.2,0.1 -0.3,0.4 -0.1,0.7l0.8,1.5l-0.9,0.5l-1.5,-2.7l0.6,-0.4l0.3,0.2c0.1,-0.3 0.3,-0.6 0.6,-0.8c0.3,-0.2 0.7,-0.2 1,0c0.1,-0.3 0.3,-0.7 0.6,-0.9C19.8,37 20.5,37.2 20.8,37.8z"/>
<path
android:fillColor="#FF000000"
android:pathData="M22.3,35.7l0.3,1.8l-1.4,-1.1l-1,0.6l2.5,1.8c0,0.2 0,0.4 -0.1,0.5l0.5,0.8c0.5,-0.4 0.6,-0.8 0.5,-1.7l-0.3,-3.2L22.3,35.7z"/>
</vector>

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
@ -13,6 +14,13 @@
<!-- Login progress -->
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="180dp"
android:contentDescription="Logo find my tutor"
app:srcCompat="@drawable/logo_design_black2" />
<ProgressBar
android:id="@+id/login_progress"
style="?android:attr/progressBarStyleLarge"

View File

@ -82,6 +82,7 @@
app:layout_anchorGravity="bottom|center"
app:menu="@menu/nav_items" />
</RelativeLayout>
<include
layout="@layout/app_bar_main"
android:layout_width="match_parent"

View File

@ -19,4 +19,5 @@
</com.mapbox.mapboxsdk.maps.MapView>
</android.support.constraint.ConstraintLayout>

View File

@ -1,32 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:mapbox="http://schemas.android.com/apk/res-auto"
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"
tools:context=".activity.NotificationsActivity">
<!--tools:context=".examples.annotations.AnimatedMarkerActivity">-->
<com.mapbox.mapboxsdk.maps.MapView
android:id="@+id/mapView2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible"
mapbox:mapbox_cameraTargetLat="52.466799"
mapbox:mapbox_cameraTargetLng="16.927002"
mapbox:mapbox_cameraZoom="17"
mapbox:mapbox_styleUrl="mapbox://styles/domagalsky/cjiyzrqjp05l72rmj6ntvv2n8">
</com.mapbox.mapboxsdk.maps.MapView>
<include
android:id="@+id/navigation"
layout="@layout/element_bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
</RelativeLayout>

View File

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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"
tools:context=".activity.ProfileActivity">
<include
android:id="@+id/navigation"
layout="@layout/element_bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
app:layout_constraintBottom_toBottomOf="parent" />
</android.support.constraint.ConstraintLayout>

View File

@ -13,6 +13,7 @@
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar

View File

@ -1,22 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:mapbox="http://schemas.android.com/apk/res-auto"
tools:context=".activity.MapFragment">
<com.mapbox.mapboxsdk.maps.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible"
mapbox:mapbox_renderTextureMode="true"
mapbox:mapbox_cameraTargetLat="52.466799"
mapbox:mapbox_cameraTargetLng="16.927002"
mapbox:mapbox_cameraZoom="17"
mapbox:mapbox_styleUrl="mapbox://styles/domagalsky/cjiyzrqjp05l72rmj6ntvv2n8">
</com.mapbox.mapboxsdk.maps.MapView>
</FrameLayout>

View File

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activity.NotificationFragment">
<!-- TODO: Update blank fragment layout -->
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Notification fragment" />
</FrameLayout>

View File

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activity.ProfileFragment">
<!-- TODO: Update blank fragment layout -->
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Profile Frag" />
</FrameLayout>

View File

@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/nav_header"
android:layout_width="match_parent"
android:layout_height="160dp"
@ -9,20 +11,15 @@
android:foreground="?attr/selectableItemBackgroundBorderless"
android:gravity="bottom"
android:orientation="vertical"
android:padding="16dp"
android:padding="4dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark">
<ImageView
android:id="@+id/nav_header_imageView"
android:layout_width="64dp"
android:layout_height="64dp"
android:src="@mipmap/ic_launcher" />
<TextView
android:id="@+id/nav_header_textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="16dp"
android:text="Chike Mgbemena"
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
android:layout_height="match_parent"
android:visibility="visible"
app:srcCompat="@drawable/logo_design_black2" />
</LinearLayout>

View File

@ -4,7 +4,7 @@
android:id="@+id/coordinator_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activity.UsersListActivity">
tools:context=".activity.UsersListFragment">
<include layout="@layout/users_list_main" />

View File

@ -7,7 +7,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".activity.UsersListActivity"
tools:context=".activity.UsersListFragment"
tools:showIn="@layout/users_list_main">

View File

@ -1,34 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group>
<item android:id="@+id/nav_item_one"
android:icon="@drawable/ic_menu_camera"
android:title="Item 1" />
<item android:id="@+id/nav_item_two"
android:icon="@drawable/ic_menu_gallery"
android:title="Item 2" />
<item android:id="@+id/nav_item_three"
android:icon="@drawable/ic_menu_share"
android:title="Item 3" />
</group>
<group android:id="@+id/group_menu">
<item android:id="@+id/nav_item_four"
<item
android:id="@+id/nav_item_one"
android:icon="@drawable/ic_people_white"
android:title="@string/action_white_list" />
<item android:id="@+id/nav_item_five"
android:title="@string/navigation_item_whitelist" />
<item
android:id="@+id/nav_item_two"
android:icon="@drawable/ic_people_black"
android:title="@string/action_black_list" />
android:title="@string/navigation_item_blacklist" />
<item
android:id="@+id/nav_item_three"
android:icon="@drawable/outline_person_white_24dp"
android:title="@string/navigation_item_profile" />
</group>
<group android:id="@+id/group_menu">
<item
android:id="@+id/nav_item_four"
android:icon="@drawable/ic_menu_settings_key"
android:title="@string/navigation_item_settings" />
<item
android:id="@+id/nav_item_five"
android:icon="@android:drawable/ic_lock_power_off"
android:title="@string/navigation_item_logout" />
</group>
<item android:title="Title 1">
<menu>
<item android:id="@+id/nav_item_six"
android:icon="@drawable/ic_menu_settings_gear"
android:title="@string/action_settings" />
<item android:id="@+id/nav_item_sign_out"
android:icon="@drawable/ic_menu_sign_out2"
android:title="@string/action_sign_out" />
</menu>
</item>
</menu>

View File

@ -11,7 +11,11 @@
<!--Side Menu-->
<string name="navigation_drawer_open">Drawer Open</string>
<string name="navigation_drawer_close">Drawer Closed</string>
<string name="navigation_item_blacklist">Blacklist</string>
<string name="navigation_item_whitelist">Whitelist</string>
<string name="navigation_item_settings">Settings</string>
<string name="navigation_item_profile">Profile</string>
<string name="navigation_item_logout">Log out</string>
<!-- Tutors list -->
<string name="action_settings">Settings</string>
<string name="activity_title_home">Notes</string>
@ -197,6 +201,7 @@ functionality.</string>
</plurals>
<string name="title_activity_main2">Main2Activity</string>
<string name="there_is_no_users_in_system">There is no users in system</string>
<string name="cancel">Close</string>
<string name="userRoom">Pokój</string>
@ -204,7 +209,8 @@ functionality.</string>
<string name="userNote">Notatka</string>
<string name="userDutyHoursHeader">Dyżury</string>
<string name="dutyHours">Dyżury</string>
<string name="error_invalid_login_name">Invalid format of login. Use s11111 format</string>
<string name="error_invalid_login_name">Invalid format login. Use s11111 format</string>
<string name="userDepartment">Zakład</string>
<string name="loading">Loading ...</string>
</resources>

View File

@ -7,7 +7,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here; they belong