Commit 0fe4e228 authored by Varun Patil's avatar Varun Patil

feat(map): Highlight locate FAB when following user (fix #277)

parent c05d4184
...@@ -7,6 +7,7 @@ import android.content.Context; ...@@ -7,6 +7,7 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentSender; import android.content.IntentSender;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.res.ColorStateList;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.PointF; import android.graphics.PointF;
import android.graphics.Typeface; import android.graphics.Typeface;
...@@ -340,7 +341,7 @@ public class MapFragment extends Fragment implements TextWatcher, ...@@ -340,7 +341,7 @@ public class MapFragment extends Fragment implements TextWatcher,
} }
private void locate(boolean showWarning) { private void locate(boolean showWarning) {
followingUser = true; setFollowingUser(true);
if (!GPSIsSetup) { if (!GPSIsSetup) {
displayLocationSettingsRequest(showWarning); displayLocationSettingsRequest(showWarning);
} else if (user != null) { } else if (user != null) {
...@@ -1030,10 +1031,6 @@ public class MapFragment extends Fragment implements TextWatcher, ...@@ -1030,10 +1031,6 @@ public class MapFragment extends Fragment implements TextWatcher,
} }
} }
public void setFollowingUser(boolean followingUser) {
this.followingUser = followingUser;
}
private void displayLocationSettingsRequest(final boolean showWarning) { private void displayLocationSettingsRequest(final boolean showWarning) {
if (getView() == null || getActivity() == null) return; if (getView() == null || getActivity() == null) return;
LocationRequest mLocationRequest = LocationRequest.create() LocationRequest mLocationRequest = LocationRequest.create()
...@@ -1162,5 +1159,18 @@ public class MapFragment extends Fragment implements TextWatcher, ...@@ -1162,5 +1159,18 @@ public class MapFragment extends Fragment implements TextWatcher,
public static String getPassableName(String name) { public static String getPassableName(String name) {
return name.toLowerCase().replace(" ", "-").replaceAll("[^A-Za-z0-9\\-]", ""); return name.toLowerCase().replace(" ", "-").replaceAll("[^A-Za-z0-9\\-]", "");
} }
public void setFollowingUser(boolean followingUser) {
if (getView() == null) return;
FloatingActionButton fab = getView().findViewById(R.id.locate_fab);
if (followingUser) {
fab.setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.colorPrimary))) ;
fab.setColorFilter(getResources().getColor(R.color.primaryTextColor));
} else {
fab.setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.colorAccent))) ;
fab.setColorFilter(getResources().getColor(R.color.secondaryTextColor));
}
this.followingUser = followingUser;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment