diff --git a/app/build.gradle b/app/build.gradle index 595676b..9d862f9 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -57,4 +57,7 @@ dependencies { implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1' implementation 'com.auth0.android:jwtdecode:1.1.1' + // FloatingBarMenu + implementation 'com.getbase:floatingactionbutton:1.10.1' + } 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 37c7a00..d93fa9c 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 @@ -36,6 +36,9 @@ public abstract class BaseActivity extends AppCompatActivity implements BottomNavigationView.OnNavigationItemSelectedListener { + String tag = getClass().getName(); + + protected BottomNavigationView navigationView; protected Toolbar toolbar; @@ -52,8 +55,6 @@ public abstract class BaseActivity private boolean isTutor; - - @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -108,16 +109,15 @@ public abstract class BaseActivity setUpNav(); actionBarDrawerToggle.syncState(); - Log.e("erororr", "guewa!" + isTutor); // if (isTutor && getContentViewId() == R.layout.activity_map) { - if (isTutor) { + if (isTutor) { Log.e("erororr", "taaaaaak!"); fn_permission(); } } - private void 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))) { @@ -152,10 +152,10 @@ 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); + MenuItem myActionMenuItem = menu.findItem(R.id.action_search); final SearchView searchView = (SearchView) myActionMenuItem.getActionView(); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override @@ -210,7 +210,7 @@ public abstract class BaseActivity @Override public void onPause() { super.onPause(); - overridePendingTransition(0,0); + overridePendingTransition(0, 0); } private void setFragment(Fragment fragment) { @@ -229,7 +229,6 @@ public abstract class BaseActivity public boolean onNavigationItemSelected(@NonNull MenuItem item) { - navigationView.postDelayed(() -> { int itemId = item.getItemId(); if (itemId == R.id.nav_map) { 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 b3e7dd6..188b002 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 @@ -11,6 +11,21 @@ import android.os.Handler; import android.support.design.widget.FloatingActionButton; import android.util.Log; + +import com.mapbox.mapboxsdk.style.layers.CircleLayer; +import com.mapbox.mapboxsdk.style.layers.Layer; +import com.mapbox.mapboxsdk.style.layers.SymbolLayer; +import com.mapbox.mapboxsdk.style.sources.VectorSource; +import static com.mapbox.mapboxsdk.style.layers.Property.NONE; +import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleColor; +import android.graphics.Color; +import android.view.View; +import android.widget.Toast; + +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleRadius; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility; + import com.mapbox.mapboxsdk.Mapbox; import com.mapbox.mapboxsdk.annotations.Marker; import com.mapbox.mapboxsdk.annotations.MarkerOptions; @@ -19,6 +34,7 @@ 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.mapbox.mapboxsdk.style.layers.Layer; import com.uam.wmi.findmytutor.R; import com.uam.wmi.findmytutor.model.Coordinate; import com.uam.wmi.findmytutor.network.RetrofitClientInstance; @@ -42,8 +58,6 @@ public class MapActivity extends BaseActivity String tag = getClass().getName(); - - private MapView mapView; private MapboxMap mapboxMap; private int mInterval = 10000; @@ -63,6 +77,8 @@ public class MapActivity extends BaseActivity protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); configureLogoutButton(); + configureToggleMarkerLayerButton(); + final SharedPreferences sharedPref = getSharedPreferences("fmtPrefs", Context.MODE_PRIVATE); final String authToken = sharedPref.getString("authToken", null); @@ -109,8 +125,37 @@ public class MapActivity extends BaseActivity markerAnimator.start(); } }); + + + + // TODO here we create static layer, we are able to hide/show (but we cannot put markers inthere) + VectorSource museums = new VectorSource("museums_source", "mapbox://mapbox.2opop9hr"); + mapboxMap.addSource(museums); + + CircleLayer museumsLayer = new CircleLayer("museums", "museums_source"); + museumsLayer.setSourceLayer("museum-cusco"); + museumsLayer.setProperties( + visibility(VISIBLE), + circleRadius(8f), + circleColor(Color.argb(255, 55, 148, 179)) + ); + mapboxMap.addLayer(museumsLayer); + + // TODO what should happend on click? + mapboxMap.setOnMarkerClickListener(new MapboxMap.OnMarkerClickListener() { + @Override + public boolean onMarkerClick(@NonNull Marker marker) { + + // Show a toast with the title of the selected marker + Toast.makeText(MapActivity.this, marker.getTitle(), Toast.LENGTH_SHORT).show(); + return true; + } + }); + + } + private static class LatLngEvaluator implements TypeEvaluator { // Method is used to interpolate the marker animation. @@ -169,8 +214,6 @@ public class MapActivity extends BaseActivity } - - } else { Log.e(tag, "Marker Added: " + id); coordsMap.put(id, element); @@ -208,6 +251,23 @@ public class MapActivity extends BaseActivity }); } + private void configureToggleMarkerLayerButton() { + // Toggle layer button + final FloatingActionButton button = findViewById(R.id.toggleMarkerLayerButton); + + button.setOnClickListener(view -> { + + Layer layer = mapboxMap.getLayer("museums"); + if (layer != null) { + if (VISIBLE.equals(layer.getVisibility().getValue())) { + layer.setProperties(visibility(NONE)); + } else { + layer.setProperties(visibility(VISIBLE)); + } + } + }); + } + // Add the mapView lifecycle to the activity's lifecycle methods @Override diff --git a/app/src/main/res/drawable-v24/fab_label_background.xml b/app/src/main/res/drawable-v24/fab_label_background.xml new file mode 100644 index 0000000..0d8c05b --- /dev/null +++ b/app/src/main/res/drawable-v24/fab_label_background.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_map.xml b/app/src/main/res/layout/activity_map.xml index 282f395..3a045b5 100644 --- a/app/src/main/res/layout/activity_map.xml +++ b/app/src/main/res/layout/activity_map.xml @@ -2,6 +2,7 @@ - + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 5a62888..4b6cea9 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -46,4 +46,9 @@ http://findmytutor.projektstudencki.pl/terms-of-service/ Wersja Wybierz klienta poczty + + + Hotele + Parkingi + Atrakcje \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 387faef..ee47919 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -1,16 +1,76 @@ - #3F51B5 - #303F9F - #9ef13f - #999 + @color/mapboxGray + @color/mapboxGrayDark10 + @color/mapboxPink + #cf5e5e #89c3c3c3 #858585 #232323 - #ffffff + #d1e200f6 #ffffff #80ffffff + + #F5F5F5 + #DFDFDF + + #FFFFFF + + #269561 + #33c377 + #afdec5 + #e8f5ee + + #4264fb + #314ccd + #aab7ef + #edf0fd + + #273d56 + #476483 + #2d3c4f + #607d9c + #c6d2e1 + #f4f7fb + + #b43b71 + #ee4e8b + #f8c8da + #fbe5ee + + #5a3fc0 + #5E3AD2 + #7753eb + #c5b9eb + #916DFF + #f2effa + + #136174 + #11b4da + #a4deeb + #d7f1f6 + + #ba7334 + #f79640 + #fbcea6 + #feefe2 + + #ba3b3f + #f74e4e + #f6b7b7 + #fbe5e5 + + #a4a62d + #d9d838 + #FFF5A0 + #FCFCDF + + + #B2000000 + #808080 + #f1f1f1 + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f5d9839..367e402 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -197,4 +197,10 @@ functionality. Main2Activity + + + Hotels + Parks + Attractions + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index edb90df..ad4f49e 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -18,5 +18,8 @@