diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..646dfea --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ce8be37..f29338f 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -18,7 +18,7 @@ android:theme="@style/AppTheme"> @@ -44,9 +44,6 @@ android:name=".activity.SharingActivity" android:label="@string/title_activity_sharing" /> - - - - - diff --git a/app/src/main/java/com/uam/wmi/findmytutor/ListViewAdapter.java b/app/src/main/java/com/uam/wmi/findmytutor/ListViewAdapter.java deleted file mode 100644 index 8fd91a7..0000000 --- a/app/src/main/java/com/uam/wmi/findmytutor/ListViewAdapter.java +++ /dev/null @@ -1,109 +0,0 @@ -package com.uam.wmi.findmytutor; - -import android.app.Activity; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ArrayAdapter; -import android.widget.ImageView; -import android.widget.TextView; - -import com.amulyakhare.textdrawable.TextDrawable; -import com.amulyakhare.textdrawable.util.ColorGenerator; - -import com.uam.wmi.findmytutor.activity.MainActivity; - -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; - -public class ListViewAdapter extends ArrayAdapter { - - - private MainActivity activity; - private List friendList; - private List searchList; - - public ListViewAdapter(MainActivity context, int resource, List objects) { - super(context, resource, objects); - this.activity = context; - this.friendList = objects; - this.searchList = new ArrayList<>(); - this.searchList.addAll(friendList); - } - - @Override - public int getCount() { - return friendList.size(); - } - - @Override - public String getItem(int position) { - return friendList.get(position); - } - - @Override - public long getItemId(int position) { - return position; - } - - @Override - public View getView(int position, View convertView, ViewGroup parent) { - ViewHolder holder; - LayoutInflater inflater = (LayoutInflater) activity.getSystemService(Activity.LAYOUT_INFLATER_SERVICE); - // If holder not exist then locate all view from UI file. - if (convertView == null) { - // inflate UI from XML file - convertView = inflater.inflate(R.layout.item_listview, parent, false); - // get all UI view - holder = new ViewHolder(convertView); - // set tag for holder - convertView.setTag(holder); - } else { - // if holder created, get tag from view - holder = (ViewHolder) convertView.getTag(); - } - - holder.friendName.setText(getItem(position)); - - //get first letter of each String item - String firstLetter = String.valueOf(getItem(position).charAt(0)); - - ColorGenerator generator = ColorGenerator.MATERIAL; // or use DEFAULT - // generate random color - int color = generator.getColor(getItem(position)); - - TextDrawable drawable = TextDrawable.builder() - .buildRound(firstLetter, color); // radius in px - - holder.imageView.setImageDrawable(drawable); - - return convertView; - } - - // Filter method - public void filter(String charText) { - charText = charText.toLowerCase(Locale.getDefault()); - friendList.clear(); - if (charText.length() == 0) { - friendList.addAll(searchList); - } else { - for (String s : searchList) { - if (s.toLowerCase(Locale.getDefault()).contains(charText)) { - friendList.add(s); - } - } - } - notifyDataSetChanged(); - } - - private class ViewHolder { - private ImageView imageView; - private TextView friendName; - - public ViewHolder(View v) { - imageView = (ImageView) v.findViewById(R.id.image_view); - friendName = (TextView) v.findViewById(R.id.text); - } - } -} \ No newline at end of file diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/BaseActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/BaseActivity.java index 4b0e776..37c7a00 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/BaseActivity.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/BaseActivity.java @@ -1,9 +1,15 @@ 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.support.annotation.NonNull; import android.support.design.widget.BottomNavigationView; +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; @@ -12,16 +18,17 @@ import android.os.Bundle; import android.support.v7.widget.SearchView; import android.support.v7.widget.Toolbar; import android.text.TextUtils; +import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.View; -import android.widget.AdapterView; import android.widget.FrameLayout; import android.widget.ListView; import android.widget.Toast; -import com.uam.wmi.findmytutor.ListViewAdapter; import com.uam.wmi.findmytutor.R; +import com.uam.wmi.findmytutor.service.BackgroundLocalizationService; +import com.uam.wmi.findmytutor.utils.PrefUtils; import java.util.ArrayList; @@ -38,7 +45,13 @@ public abstract class BaseActivity // 4 search private ListView listView; private ArrayList stringArrayList; - private ListViewAdapter adapter; + private SharingFragment sharingFragment; + + private static final int REQUEST_PERMISSIONS = 100; + boolean boolean_permission; + private boolean isTutor; + + @Override @@ -48,6 +61,12 @@ public abstract class BaseActivity navigationView = findViewById(R.id.navigation); navigationView.setOnNavigationItemSelectedListener(this); + sharingFragment = new SharingFragment(); + + isTutor = PrefUtils.getIsTutor(getApplicationContext()); + if (!isTutor) { + navigationView.findViewById(R.id.nav_profile).setVisibility(View.GONE); + } } @@ -65,23 +84,6 @@ public abstract class BaseActivity toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); } - private void setData() { - stringArrayList = new ArrayList<>(); - stringArrayList.add("Quynh Trang"); - stringArrayList.add("Hoang Bien"); - stringArrayList.add("Duc Tuan"); - stringArrayList.add("Dang Thanh"); - stringArrayList.add("Xuan Luu"); - stringArrayList.add("Phan Thanh"); - stringArrayList.add("Kim Kien"); - stringArrayList.add("Ngo Trang"); - stringArrayList.add("Thanh Ngan"); - stringArrayList.add("Nguyen Duong"); - stringArrayList.add("Quoc Cuong"); - stringArrayList.add("Tran Ha"); - stringArrayList.add("Vu Danh"); - stringArrayList.add("Minh Meo"); - } private void setUpNav() { @@ -106,6 +108,41 @@ public abstract class BaseActivity setUpNav(); actionBarDrawerToggle.syncState(); + Log.e("erororr", "guewa!" + isTutor); + +// if (isTutor && getContentViewId() == R.layout.activity_map) { + if (isTutor) { + Log.e("erororr", "taaaaaak!"); + 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 @@ -129,10 +166,10 @@ public abstract class BaseActivity @Override public boolean onQueryTextChange(String newText) { if (TextUtils.isEmpty(newText)) { - adapter.filter(""); - listView.clearTextFilter(); + //adapter.filter(""); + //listView.clearTextFilter(); } else { - adapter.filter(newText); + //adapter.filter(newText); } return true; } @@ -149,6 +186,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(); @@ -161,36 +213,41 @@ public abstract class BaseActivity overridePendingTransition(0,0); } + private void setFragment(Fragment fragment) { + FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); + fragmentTransaction.replace(R.id.activity_content, fragment); + fragmentTransaction.commit(); + } + + private void removeFragment(Fragment fragment) { + FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); + fragmentTransaction.remove(fragment); + fragmentTransaction.commit(); + } + @Override public boolean onNavigationItemSelected(@NonNull MenuItem item) { + + navigationView.postDelayed(() -> { int itemId = item.getItemId(); if (itemId == R.id.nav_map) { - startActivity(new Intent(this, MapActivity.class)); - } else if (itemId == R.id.nav_profile) { - startActivity(new Intent(this, ProfileActivity.class)); - } else if (itemId == R.id.nav_notif) { - startActivity(new Intent(this, NotificationsActivity.class)); - } - finish(); - }, 300); - return true; + removeFragment(sharingFragment); -// navigationView.postDelayed(() -> { -// int itemId = item.getItemId(); -// switch (itemId) { -// case R.id.nav_profile: -// startActivity(new Intent(this, ProfileActivity.class)); -// case R.id.nav_map: -// startActivity(new Intent(this, MapActivity.class)); -// case R.id.nav_notif: -// startActivity(new Intent(this, NotificationsActivity.class)); -// } -// -// finish(); -// }, 300); -// return true; + // startActivity(new Intent(this, MapActivity.class)); + } else if (itemId == R.id.nav_profile) { + // startActivity(new Intent(this, ProfileActivity.class)); + setFragment(sharingFragment); + + } else if (itemId == R.id.nav_notif) { + //startActivity(new Intent(this, NotificationsActivity.class)); + setFragment(sharingFragment); + } + //finish(); + }, 300); + + return true; } private void updateNavigationBarState() { diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/MainActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/MainActivity.java deleted file mode 100644 index 6d040a3..0000000 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/MainActivity.java +++ /dev/null @@ -1,293 +0,0 @@ -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.design.widget.BottomNavigationView; -import android.support.design.widget.FloatingActionButton; -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.support.v7.widget.SearchView; -import android.support.v7.widget.Toolbar; -import android.text.TextUtils; -import android.view.Menu; -import android.view.MenuItem; -import android.view.View; -import android.widget.FrameLayout; -import android.widget.ListView; -import android.widget.Toast; - -import com.mapbox.mapboxsdk.Mapbox; -import com.mapbox.mapboxsdk.maps.MapFragment; -import com.uam.wmi.findmytutor.ListViewAdapter; -import com.uam.wmi.findmytutor.R; -import com.uam.wmi.findmytutor.service.BackgroundLocalizationService; -import com.uam.wmi.findmytutor.utils.PrefUtils; - -import java.util.ArrayList; - - -public class MainActivity extends AppCompatActivity { - - private BottomNavigationView mMainNav; - private FrameLayout mMainFrame; - private boolean isTutor; - private MapFragment mapFragment; - private NotificationFragment notificationFragment; - private ProfileFragment profileFragment;; - - private static final int REQUEST_PERMISSIONS = 100; - boolean boolean_permission; - - private DrawerLayout drawerLayout; - private ActionBarDrawerToggle actionBarDrawerToggle; - - - // 4 search - private ListView listView; - private ArrayList stringArrayList; - private ListViewAdapter adapter; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); - - Bundle extras = getIntent().getExtras(); - Mapbox.getInstance(this, getString(R.string.access_token)); - - configureconfigureNavigationDrawer(); - configureBottomNavigationView(); - configureLogoutButton(); - - } - - private void configureconfigureNavigationDrawer() { - listView = findViewById(R.id.list_item); - Toolbar toolbar = findViewById(R.id.toolbar_main); - setSupportActionBar(toolbar); - - setData(); - adapter = new ListViewAdapter(this, R.layout.item_listview, stringArrayList); - listView.setAdapter(adapter); - - listView.setOnItemClickListener((parent, view, position, id) -> Toast.makeText(MainActivity.this, (String)parent.getItemAtPosition(position), Toast.LENGTH_SHORT).show()); - - drawerLayout = findViewById(R.id.drawer_layout); - - actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); - drawerLayout.addDrawerListener(actionBarDrawerToggle); - - ActionBar actionBar = getSupportActionBar(); - actionBar.setDisplayShowTitleEnabled(false); - - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setHomeButtonEnabled(true); - } - - } - - private void setFragment(Fragment fragment) { - FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); - fragmentTransaction.replace(R.id.main_frame, fragment); - fragmentTransaction.commit(); - } - - private void configureBottomNavigationView(){ - - mMainFrame = findViewById(R.id.main_frame); - mMainNav = findViewById(R.id.main_nav); - isTutor = PrefUtils.getIsTutor(getApplicationContext()); - - if (!isTutor) { - mMainNav.findViewById(R.id.nav_profile).setVisibility(View.GONE); - } - - mapFragment = new MapFragment(); - notificationFragment = new NotificationFragment(); - profileFragment = new ProfileFragment(); - - // Default frag here - setFragment(mapFragment); - mMainNav.setSelectedItemId(R.id.nav_map); - - /* code below is resposible for changing colours of tabs in main tab menu */ - mMainNav.setOnNavigationItemSelectedListener(item -> { - - switch (item.getItemId()) { - case R.id.nav_map: - setFragment(mapFragment); - return true; - case R.id.nav_notif: - setFragment(notificationFragment); - return true; - case R.id.nav_profile: - setFragment(profileFragment); - return true; - default: - return false; - } - }); - } - - private void configureLogoutButton(){ - // Logout button - final FloatingActionButton button = findViewById(R.id.logoutButton); - - button.setOnClickListener(view -> { - PrefUtils.cleanUserLocalStorage(getApplicationContext()); - - Intent i = getBaseContext().getPackageManager() - .getLaunchIntentForPackage(getBaseContext().getPackageName()); - if (i != null) { - i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - } - startActivity(i); - finish(); - }); - } - - // mock 4 search bar - private void setData() { - stringArrayList = new ArrayList<>(); - stringArrayList.add("Quynh Trang"); - stringArrayList.add("Hoang Bien"); - stringArrayList.add("Duc Tuan"); - stringArrayList.add("Dang Thanh"); - stringArrayList.add("Xuan Luu"); - stringArrayList.add("Phan Thanh"); - stringArrayList.add("Kim Kien"); - stringArrayList.add("Ngo Trang"); - stringArrayList.add("Thanh Ngan"); - stringArrayList.add("Nguyen Duong"); - stringArrayList.add("Quoc Cuong"); - stringArrayList.add("Tran Ha"); - stringArrayList.add("Vu Danh"); - stringArrayList.add("Minh Meo"); - } - - @Override - 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 query) { - return false; - } - - @Override - public boolean onQueryTextChange(String newText) { - if (TextUtils.isEmpty(newText)) { - adapter.filter(""); - listView.clearTextFilter(); - } else { - adapter.filter(newText); - } - return true; - } - }); - - - return true; - } - - @Override - protected void onPostCreate(Bundle savedInstanceState) { - super.onPostCreate(savedInstanceState); - - actionBarDrawerToggle.syncState(); - - if (isTutor) { - fn_permission(); - } - - } - - @Override - public void onConfigurationChanged(Configuration newConfig) { - super.onConfigurationChanged(newConfig); - actionBarDrawerToggle.onConfigurationChanged(newConfig); - } - - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - if (actionBarDrawerToggle.onOptionsItemSelected(item)) { - return true; - } - return super.onOptionsItemSelected(item); - - } - - - private void fn_permission() { - if ((ContextCompat.checkSelfPermission(getApplicationContext(), android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED)) { - - if ((ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this, android.Manifest.permission.ACCESS_FINE_LOCATION))) { - - } else { - ActivityCompat.requestPermissions(MainActivity.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 - 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 onResume() { - super.onResume(); - } - - @Override - protected void onPause() { - super.onPause(); - } - - protected void onDestroy() { - super.onDestroy(); - } -} - - diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/MapActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/MapActivity.java index f4cb8bd..8db8e41 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/MapActivity.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/MapActivity.java @@ -1,49 +1,205 @@ 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.pm.PackageManager; -import android.os.Build; +import android.content.SharedPreferences; import android.os.Bundle; +import android.os.Handler; import android.support.design.widget.FloatingActionButton; -import android.support.v4.app.ActivityCompat; -import android.support.v4.content.ContextCompat; -import android.widget.Toast; +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.service.BackgroundLocalizationService; +import com.uam.wmi.findmytutor.model.Coordinate; +import com.uam.wmi.findmytutor.network.RetrofitClientInstance; +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 static final int REQUEST_PERMISSIONS = 100; - private boolean isTutor; + + + private MapView mapView; + private MapboxMap mapboxMap; + private int mInterval = 10000; + private Handler mHandler; + + private Map 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); - - isTutor = PrefUtils.getIsTutor(getApplicationContext()); - - if (isTutor) { - fn_permission(); - } - - mapView.getMapAsync(mapboxMap -> { - - // Customize map with markers, polylines, etc. - - }); - // TODO remove logout button configureLogoutButton(); + + final SharedPreferences sharedPref = getSharedPreferences("fmtPrefs", Context.MODE_PRIVATE); + final String authToken = sharedPref.getString("authToken",null); + + mStatusChecker = new Runnable() { + @Override + public void run() { + try{ + fetchTopCoords(); + } finally { + mHandler.postDelayed(mStatusChecker, mInterval); + } + } + }; + + coordinateService = RetrofitClientInstance.createService(CoordinateService.class,"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1laWQiOiJhM2MxMDU1YS1kZDM0LTQ5ZWItYTFkNS0xY2E5YTE2YzY0ODgiLCJzdWIiOiJzdHJpbmciLCJqdGkiOiI4NTA0NDA5NS00NjBkLTQzZDgtYjMxMC0xYmNiNWMxNGExZjQiLCJleHAiOjE1NDMzNTAzMzQsImlzcyI6Imh0dHA6Ly9maW5kbXl0dXRvci5jb20iLCJhdWQiOiJodHRwOi8vZmluZG15dHV0b3IuY29tIn0.xGyu6iBeq9xF0ufBd01jNzILLq1NeYa-5MeVOiPahD8"); + + 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 { + // 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>() { + @Override + public void onSuccess(List 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()); + } + }) + ); + + } + + private void configureLogoutButton(){ + // Logout button + final FloatingActionButton button = findViewById(R.id.logoutButton); + + button.setOnClickListener(view -> { + PrefUtils.cleanUserLocalStorage(getApplicationContext()); + + Intent i = getBaseContext().getPackageManager() + .getLaunchIntentForPackage(getBaseContext().getPackageName()); + if (i != null) { + i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + } + startActivity(i); + finish(); + }); } @@ -83,6 +239,8 @@ public class MapActivity extends BaseActivity { protected void onDestroy() { super.onDestroy(); mapView.onDestroy(); + mHandler.removeCallbacks(mStatusChecker); + disposable.dispose(); } @Override @@ -91,51 +249,6 @@ public class MapActivity extends BaseActivity { mapView.onSaveInstanceState(outState); } - private void configureLogoutButton(){ - // Logout button - final FloatingActionButton button = findViewById(R.id.logoutButton); - - button.setOnClickListener(view -> { - PrefUtils.cleanUserLocalStorage(getApplicationContext()); - - Intent i = getBaseContext().getPackageManager() - .getLaunchIntentForPackage(getBaseContext().getPackageName()); - if (i != null) { - i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - } - startActivity(i); - finish(); - }); - } - - 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; diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/MapFragment.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/MapFragment.java deleted file mode 100644 index d8c1e36..0000000 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/MapFragment.java +++ /dev/null @@ -1,98 +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.mapbox.mapboxsdk.maps.MapView; -import com.uam.wmi.findmytutor.R; -import com.uam.wmi.findmytutor.network.ApiClient; -import com.uam.wmi.findmytutor.service.CoordinateService; - -import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext; - -/** - * A simple {@link Fragment} subclass. - */ -public class MapFragment extends Fragment { - private MapView mapView; - - - public MapFragment() { - // 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_map, container, false); - } - - @Override - public void onViewCreated(View view, Bundle savedInstanceState) { - super.onViewCreated(view, savedInstanceState); - - mapView = (MapView) view.findViewById(R.id.mapView); - mapView.onCreate(savedInstanceState); - CoordinateService service = ApiClient.getClient(getApplicationContext()) - .create(CoordinateService.class); - } - - @Override - public void onStart() { - super.onStart(); - mapView.onStart(); - } - - @Override - public void onResume() { - super.onResume(); - mapView.onResume(); - - } - - @Override - public void onPause() { - super.onPause(); - mapView.onPause(); - } - - @Override - public void onStop() { - super.onStop(); - mapView.onStop(); - } - - @Override - public void onLowMemory() { - super.onLowMemory(); - mapView.onLowMemory(); - } - - @Override - public void onDestroyView() { - super.onDestroyView(); - mapView.onDestroy(); - } - -// @Override -// public void onDestroy() { -// super.onDestroy(); -// mapView.onDestroy(); -// } - - @Override - public void onSaveInstanceState(Bundle outState) { - super.onSaveInstanceState(outState); - mapView.onSaveInstanceState(outState); - } - - - -} diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/NotificationFragment.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/NotificationFragment.java deleted file mode 100644 index 431777b..0000000 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/NotificationFragment.java +++ /dev/null @@ -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); - } - -} diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/NotificationsActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/NotificationsActivity.java deleted file mode 100644 index 6af733e..0000000 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/NotificationsActivity.java +++ /dev/null @@ -1,266 +0,0 @@ -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.SharedPreferences; -import android.os.Bundle; -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.RetrofitClientInstance; -import com.uam.wmi.findmytutor.service.CoordinateService; - -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 NotificationsActivity extends BaseActivity implements - OnMapReadyCallback { - - private int mInterval = 10000; - private Handler mHandler; - - private MapView mapView; - private MapboxMap mapboxMap; - private Map coordsMap = new HashMap<>(); - - private CoordinateService coordinateService; - private CompositeDisposable disposable = new CompositeDisposable(); - - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - // This contains the MapView in XML and needs to be called after the access token is configured. - setContentView(R.layout.activity_notifications); - - - // mapInit(savedInstanceState); - - // Mapbox access token is configured here. This needs to be called either in your application - // object or in the same activity which contains the mapview. - Mapbox.getInstance(this, getString(R.string.access_token)); - - - - mapView = findViewById(R.id.mapView2); - mapView.onCreate(savedInstanceState); - mapView.getMapAsync(this); - - - final SharedPreferences sharedPref = getSharedPreferences("fmtPrefs", Context.MODE_PRIVATE); - final String authToken = sharedPref.getString("authToken",null); - - coordinateService = RetrofitClientInstance.createService(CoordinateService.class,"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1laWQiOiI2YjhmNzFiMS00NDM2LTQxZGQtYjg3MC1mNzZlNjdkNDM4NDMiLCJzdWIiOiJzdHJpbmciLCJqdGkiOiJiZGRjZTAwMC0xN2U4LTQwNDUtYWZiNS1kY2RkOWNhNDFiNmQiLCJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL3dzLzIwMDgvMDYvaWRlbnRpdHkvY2xhaW1zL3JvbGUiOiJUdXRvciIsImV4cCI6MTU0MTcxNzk2MywiaXNzIjoiaHR0cDovL2ZpbmRteXR1dG9yLmNvbSIsImF1ZCI6Imh0dHA6Ly9maW5kbXl0dXRvci5jb20ifQ.JJVNeMAwwla6DJk6X8qZUgPFKJp-Epx55W9V_fIwpgg"); - - mHandler = new Handler(); - -// fetchTopCoords(); - } - - @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(); - } - }); - } - - - Runnable mStatusChecker = new Runnable() { - @Override - public void run() { - try{ - fetchTopCoords(); - } finally { - mHandler.postDelayed(mStatusChecker, mInterval); - } - } - }; -/* - private void mapInit(Bundle savedInstanceState) { - // Mapbox access token is configured here. This needs to be called either in your application - // object or in the same activity which contains the mapview. - Mapbox.getInstance(this, getString(R.string.access_token)); - // This contains the MapView in XML and needs to be called after the access token is configured. - // setContentView(R.layout.activity_notifications); - - mapView = (MapView) findViewById(R.id.mapView2); - mapView.onCreate(savedInstanceState); - mapView.getMapAsync(new OnMapReadyCallback() { - @Override - public void onMapReady(MapboxMap mapboxMap) { - - final Marker marker = mapboxMap.addMarker(new MarkerViewOptions() - .position(new LatLng(52.466782,16.927549))); - - 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 void fetchTopCoords() { - disposable.add( -// coordinateService.getTopCoordinates() - coordinateService.getOnlineCoordinates() - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .subscribeWith(new DisposableSingleObserver>() { - @Override - public void onSuccess(List 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); - } 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); - } - } 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()); - } - }) - ); - - } - - - @Override - protected void onStart() { - super.onStart(); - mapView.onStart(); - } - - @Override - public void onResume() { - super.onResume(); - mapView.onResume(); - } - - @Override - public void onPause() { - super.onPause(); - mapView.onPause(); - } - - @Override - protected void onStop() { - super.onStop(); - mapView.onStop(); - } - - @Override - public void onLowMemory() { - super.onLowMemory(); - mapView.onLowMemory(); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - mapView.onDestroy(); - mHandler.removeCallbacks(mStatusChecker); - disposable.dispose(); - } - - @Override - protected void onSaveInstanceState(Bundle outState) { - super.onSaveInstanceState(outState); - mapView.onSaveInstanceState(outState); - } - - private static class LatLngEvaluator implements TypeEvaluator { - // 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; - } - } - - @Override - protected int getContentViewId() { return R.layout.activity_notifications; } - - @Override - protected int getNavigationMenuItemId() { return R.id.nav_notif; } -} diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/ProfileActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/ProfileActivity.java deleted file mode 100644 index 5a3d92d..0000000 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/ProfileActivity.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.uam.wmi.findmytutor.activity; - -import com.uam.wmi.findmytutor.R; - -public class ProfileActivity extends BaseActivity { - - @Override - protected int getContentViewId() { return R.layout.activity_profile; } - - @Override - protected int getNavigationMenuItemId() { - return R.id.nav_profile; - } -} diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/ProfileFragment.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/ProfileFragment.java deleted file mode 100644 index d994bfd..0000000 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/ProfileFragment.java +++ /dev/null @@ -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); - } - -} diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/SettingsActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/SettingsActivity.java index 13b75a1..c20fb4c 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/SettingsActivity.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/SettingsActivity.java @@ -31,7 +31,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity { @Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); - addPreferencesFromResource(R.xml.pref_main); + addPreferencesFromResource(R.layout.pref_main); //TODO add on change listeners for preferences diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/SharingActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/SharingActivity.java index 30d5465..a989f0e 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/SharingActivity.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/SharingActivity.java @@ -36,7 +36,7 @@ public class SharingActivity extends AppCompatPreferenceActivity { @Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); - addPreferencesFromResource(R.xml.pref_sharing); + addPreferencesFromResource(R.layout.pref_sharing); Preference manualStatus = findPreference("key_manual_status"); manualStatus.setOnPreferenceChangeListener((preference, newValue) -> { diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/SharingFragment.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/SharingFragment.java new file mode 100644 index 0000000..586fa13 --- /dev/null +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/SharingFragment.java @@ -0,0 +1,85 @@ +package com.uam.wmi.findmytutor.activity; + +import android.content.Context; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.preference.ListPreference; +import android.preference.Preference; +import android.preference.PreferenceFragment; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import com.uam.wmi.findmytutor.R; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +//public class SharingFragment { +//} + +public class SharingFragment extends PreferenceFragment { + @Override + public void onCreate(final Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + addPreferencesFromResource(R.layout.pref_sharing); + Preference manualStatus = findPreference("key_manual_status"); + manualStatus.setOnPreferenceChangeListener((preference, newValue) -> { + ListPreference lp = (ListPreference) findPreference("key_status_value"); + updateListPreference(lp, newValue, "manual_statuses"); + return true; + }); + + /* Preference manualLocation = findPreference("key_sharing_enabled"); + manualLocation.setOnPreferenceChangeListener((preference, newValue) -> { + ListPreference lp = (ListPreference) findPreference("key_sharing_enabled"); + updateListPreference(lp, newValue, "sharing_enabled"); + return true; + });*/ + + Preference sharingLocation = findPreference("key_sharing_enabled"); + sharingLocation.setOnPreferenceChangeListener((preference, o) -> { + Log.e("change", "1"); + return false; + }); + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + View view = super.onCreateView(inflater, container, savedInstanceState); + view.setBackgroundColor(getResources().getColor(android.R.color.white)); + + return view; + } + + protected void updateListPreference(ListPreference lp,Object newValue,String storageKey){ + CharSequence [] entries = lp.getEntries(); + Set defaultEntries = new HashSet(Arrays.asList(entries)); + SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE); + Set manualStatusSet = sharedPref.getStringSet(storageKey,defaultEntries); + manualStatusSet.add((String) newValue); + String [] manualStatusArr = manualStatusSet.toArray(new String[0]); + Arrays.sort(manualStatusArr); + setListPreferenceData(lp.getKey(),manualStatusArr); + SharedPreferences.Editor editor = sharedPref.edit(); + editor.putStringSet(storageKey,manualStatusSet); + editor.commit(); + } + + protected ListPreference setListPreferenceData(String lp_name, String [] entries) { + ListPreference lp = (ListPreference) findPreference(lp_name); + lp.setEntries(entries); + CharSequence[] entryValues = new CharSequence [entries.length]; + + for (int i = 0; i < entries.length; i++){ + entryValues[i] = Integer.toString(i+1); + } + + lp.setDefaultValue("1"); + lp.setEntryValues(entryValues); + + return lp; + } +} diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/StartupActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/StartupActivity.java index 04dfc8b..934b486 100644 --- a/app/src/main/java/com/uam/wmi/findmytutor/activity/StartupActivity.java +++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/StartupActivity.java @@ -2,8 +2,9 @@ package com.uam.wmi.findmytutor.activity; import android.app.Activity; import android.content.Intent; -import android.support.v7.app.AppCompatActivity; import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; + import com.uam.wmi.findmytutor.utils.PrefUtils; diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 807eab3..1b3c6cc 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -1,6 +1,7 @@ + + + + diff --git a/app/src/main/res/layout/activity_map.xml b/app/src/main/res/layout/activity_map.xml index 8b3659c..282f395 100644 --- a/app/src/main/res/layout/activity_map.xml +++ b/app/src/main/res/layout/activity_map.xml @@ -10,7 +10,7 @@ - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_notifications.xml b/app/src/main/res/layout/activity_notifications.xml deleted file mode 100644 index be82ea7..0000000 --- a/app/src/main/res/layout/activity_notifications.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_profile.xml b/app/src/main/res/layout/activity_profile.xml deleted file mode 100644 index 49b6e9b..0000000 --- a/app/src/main/res/layout/activity_profile.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/base_activity.xml b/app/src/main/res/layout/base_activity.xml index 2edc8cc..044f938 100644 --- a/app/src/main/res/layout/base_activity.xml +++ b/app/src/main/res/layout/base_activity.xml @@ -5,30 +5,45 @@ xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> - - - - - /> - + android:layout_height="wrap_content"> + + + + + + + + + + + + + + - - - - - - - + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_map.xml b/app/src/main/res/layout/fragment_map.xml deleted file mode 100644 index 6a6d89f..0000000 --- a/app/src/main/res/layout/fragment_map.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_notification.xml b/app/src/main/res/layout/fragment_notification.xml deleted file mode 100644 index 2cd9409..0000000 --- a/app/src/main/res/layout/fragment_notification.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_profile.xml b/app/src/main/res/layout/fragment_profile.xml deleted file mode 100644 index f98dfe6..0000000 --- a/app/src/main/res/layout/fragment_profile.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/xml/pref_main.xml b/app/src/main/res/layout/pref_main.xml similarity index 100% rename from app/src/main/res/xml/pref_main.xml rename to app/src/main/res/layout/pref_main.xml diff --git a/app/src/main/res/xml/pref_sharing.xml b/app/src/main/res/layout/pref_sharing.xml similarity index 92% rename from app/src/main/res/xml/pref_sharing.xml rename to app/src/main/res/layout/pref_sharing.xml index a06258b..4a75c7b 100644 --- a/app/src/main/res/xml/pref_sharing.xml +++ b/app/src/main/res/layout/pref_sharing.xml @@ -1,7 +1,10 @@ + xmlns:app="http://schemas.android.com/apk/res-auto" + tools:ignore="MissingDefaultResource" + android:layout_width="match_parent" + android:layout_height="match_parent"> - + + \ No newline at end of file