Colors + strings added

FloatingMenu with buttons ready to connect with layers
This commit is contained in:
Adam Domagalski 2018-10-31 22:24:26 +01:00
parent c67d4ba4c8
commit fe13bee1f5
9 changed files with 239 additions and 30 deletions

View File

@ -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'
}

View File

@ -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) {

View File

@ -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<LatLng> {
// 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

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/black_semi_transparent"/>
<padding
android:left="16dp"
android:top="4dp"
android:right="16dp"
android:bottom="4dp"/>
<corners
android:radius="2dp"/>
</shape>

View File

@ -2,6 +2,7 @@
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:mapbox="http://schemas.android.com/apk/res-auto"
xmlns:fab="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
@ -18,14 +19,75 @@
mapbox:mapbox_styleUrl="mapbox://styles/domagalsky/cjiyzrqjp05l72rmj6ntvv2n8">
</com.mapbox.mapboxsdk.maps.MapView>
<android.support.design.widget.FloatingActionButton
android:id="@+id/logoutButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="@dimen/fab_margin"
android:layout_marginTop="77dp"
app:backgroundTint="@android:color/holo_red_dark"
app:srcCompat="@android:drawable/ic_lock_power_off" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.design.widget.FloatingActionButton
android:id="@+id/logoutButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_marginTop="77dp"
android:layout_marginRight="@dimen/fab_margin"
app:backgroundTint="@android:color/holo_red_dark"
app:srcCompat="@android:drawable/ic_lock_power_off" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/toggleMarkerLayerButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:clickable="true"
app:backgroundTint="@color/msg_no_notes"
app:layout_constraintTop_toBottomOf="@+id/logoutButton"
mapbox:srcCompat="@android:drawable/ic_dialog_map"
tools:layout_editor_absoluteX="0dp" />
<com.getbase.floatingactionbutton.FloatingActionsMenu
android:id="@+id/multiple_actions_parent_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="16dp"
fab:fab_addButtonColorNormal="@color/mapboxRed"
fab:fab_addButtonColorPressed="@color/mapboxWhite"
fab:fab_addButtonPlusIconColor="@color/mapboxWhite"
fab:fab_labelStyle="@style/menu_labels_style"
tools:layout_editor_absoluteX="200dp"
tools:layout_editor_absoluteY="255dp">
<com.getbase.floatingactionbutton.FloatingActionButton
android:id="@+id/fab_toggle_hotels"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
fab:fab_colorNormal="@color/mapboxBlue"
fab:fab_colorPressed="@color/mapboxWhite"
fab:fab_size="mini"
fab:fab_title="@string/fab_title_hotels" />
<com.getbase.floatingactionbutton.FloatingActionButton
android:id="@+id/fab_toggle_parks"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
fab:fab_colorNormal="@color/mapboxGreen"
fab:fab_colorPressed="@color/mapboxWhite"
fab:fab_size="mini"
fab:fab_title="@string/fab_title_parks" />
<com.getbase.floatingactionbutton.FloatingActionButton
android:id="@+id/fab_toggle_attractions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
fab:fab_colorNormal="@color/mapboxRed"
fab:fab_colorPressed="@color/mapboxWhite"
fab:fab_size="mini"
fab:fab_title="@string/fab_title_attractions" />
</com.getbase.floatingactionbutton.FloatingActionsMenu>
</LinearLayout>
</android.support.constraint.ConstraintLayout>

View File

@ -46,4 +46,9 @@
<string name="url_terms">http://findmytutor.projektstudencki.pl/terms-of-service/</string>
<string name="title_version">Wersja</string>
<string name="choose_email_client">Wybierz klienta poczty</string>
<!--PulsingLayerOpacityColorActivity activity-->
<string name="fab_title_hotels">Hotele</string>
<string name="fab_title_parks">Parkingi</string>
<string name="fab_title_attractions">Atrakcje</string>
</resources>

View File

@ -1,16 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#9ef13f</color>
<color name="msg_no_notes">#999</color>
<color name="colorPrimary">@color/mapboxGray</color>
<color name="colorPrimaryDark">@color/mapboxGrayDark10</color>
<color name="colorAccent">@color/mapboxPink</color>
<color name="msg_no_notes">#cf5e5e</color>
<color name="hint_enter_note">#89c3c3c3</color>
<color name="timestamp">#858585</color>
<color name="note_list_text">#232323</color>
<color name="colorWhite">#ffffff</color>
<color name="colorWhite">#d1e200f6</color>
<color name="white">#ffffff</color>
<color name="colorWhiteTransparent">#80ffffff</color>
<color name="materialGrey">#F5F5F5</color>
<color name="materialDarkGrey">#DFDFDF</color>
<color name="mapboxWhite">#FFFFFF</color>
<color name="mapboxGreenDark">#269561</color>
<color name="mapboxGreen">#33c377</color>
<color name="mapboxGreenLight">#afdec5</color>
<color name="mapboxGreenFaint">#e8f5ee</color>
<color name="mapboxBlue">#4264fb</color>
<color name="mapboxBlueDark">#314ccd</color>
<color name="mapboxBlueLight">#aab7ef</color>
<color name="mapboxBlueFaint">#edf0fd</color>
<color name="mapboxGrayDark">#273d56</color>
<color name="mapboxGrayDark10">#476483</color>
<color name="mapboxGrayExtraDark">#2d3c4f</color>
<color name="mapboxGray">#607d9c</color>
<color name="mapboxGrayLight">#c6d2e1</color>
<color name="mapboxGrayFaint">#f4f7fb</color>
<color name="mapboxPinkDark">#b43b71</color>
<color name="mapboxPink">#ee4e8b</color>
<color name="mapboxPinkLight">#f8c8da</color>
<color name="mapboxPinkFaint">#fbe5ee</color>
<color name="mapboxPurpleDark">#5a3fc0</color>
<color name="mapboxPurpleDark10">#5E3AD2</color>
<color name="mapboxPurple">#7753eb</color>
<color name="mapboxPurpleLight">#c5b9eb</color>
<color name="mapboxPurpleLight10">#916DFF</color>
<color name="mapboxPurpleFaint">#f2effa</color>
<color name="mapboxTealDark">#136174</color>
<color name="mapboxTeal">#11b4da</color>
<color name="mapboxTealLight">#a4deeb</color>
<color name="mapboxTealFaint">#d7f1f6</color>
<color name="mapboxOrangeDark">#ba7334</color>
<color name="mapboxOrange">#f79640</color>
<color name="mapboxOrangeLight">#fbcea6</color>
<color name="mapboxOrangeFaint">#feefe2</color>
<color name="mapboxRedDark">#ba3b3f</color>
<color name="mapboxRed">#f74e4e</color>
<color name="mapboxRedLight">#f6b7b7</color>
<color name="mapboxRedFaint">#fbe5e5</color>
<color name="mapboxYellowDark">#a4a62d</color>
<color name="mapboxYellow">#d9d838</color>
<color name="mapboxYellowLight">#FFF5A0</color>
<color name="mapboxYellowFaint">#FCFCDF</color>
<!-- FAB menu colors -->
<color name="black_semi_transparent">#B2000000</color>
<color name="half_black">#808080</color>
<color name="white_pressed">#f1f1f1</color>
</resources>

View File

@ -197,4 +197,10 @@ functionality.</string>
</plurals>
<string name="title_activity_main2">Main2Activity</string>
<!--PulsingLayerOpacityColorActivity activity-->
<string name="fab_title_hotels">Hotels</string>
<string name="fab_title_parks">Parks</string>
<string name="fab_title_attractions">Attractions</string>
</resources>

View File

@ -18,5 +18,8 @@
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="menu_labels_style">
<item name="android:background">@drawable/fab_label_background</item>
<item name="android:textColor">@color/mapboxWhite</item>
</style>
</resources>