diff --git a/OsmAnd/src/net/osmand/AndroidUtils.java b/OsmAnd/src/net/osmand/AndroidUtils.java index 4c9684bf93..e391c33b02 100644 --- a/OsmAnd/src/net/osmand/AndroidUtils.java +++ b/OsmAnd/src/net/osmand/AndroidUtils.java @@ -14,6 +14,7 @@ import android.os.Build; import android.os.IBinder; import android.support.annotation.ColorRes; import android.support.annotation.DrawableRes; +import android.support.design.widget.Snackbar; import android.support.v4.content.ContextCompat; import android.text.Spannable; import android.text.SpannableString; @@ -175,6 +176,12 @@ public class AndroidUtils { return res; } + public static void setSnackbarTextColor(Snackbar snackbar, @ColorRes int colorId) { + View view = snackbar.getView(); + TextView tv = (TextView) view.findViewById(android.support.design.R.id.snackbar_action); + tv.setTextColor(ContextCompat.getColor(view.getContext(), colorId)); + } + @SuppressLint("NewApi") @SuppressWarnings("deprecation") public static void setBackground(Context ctx, View view, boolean night, int lightResId, int darkResId) { diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java index 9bcf0354e2..97fb5541c1 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java @@ -19,9 +19,9 @@ import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.ProgressBar; -import android.widget.TextView; import android.widget.Toast; +import net.osmand.AndroidUtils; import net.osmand.Location; import net.osmand.data.LatLon; import net.osmand.plus.LockableViewPager; @@ -444,9 +444,7 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm } } }); - View snackBarView = snackbar.getView(); - TextView tv = (TextView) snackBarView.findViewById(android.support.design.R.id.snackbar_action); - tv.setTextColor(ContextCompat.getColor(mapActivity, R.color.color_dialog_buttons_dark)); + AndroidUtils.setSnackbarTextColor(snackbar, R.color.color_dialog_buttons_dark); snackbar.show(); } } @@ -491,9 +489,7 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm startActivity(intent); } }); - View snackBarView = snackbar.getView(); - TextView tv = (TextView) snackBarView.findViewById(android.support.design.R.id.snackbar_action); - tv.setTextColor(ContextCompat.getColor(mapActivity, R.color.color_dialog_buttons_dark)); + AndroidUtils.setSnackbarTextColor(snackbar, R.color.color_dialog_buttons_dark); snackbar.show(); } }; diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersGroupsFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersGroupsFragment.java index 8362f02805..b00525113f 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersGroupsFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersGroupsFragment.java @@ -20,8 +20,8 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; -import android.widget.TextView; +import net.osmand.AndroidUtils; import net.osmand.Location; import net.osmand.data.Amenity; import net.osmand.data.FavouritePoint; @@ -206,9 +206,7 @@ public class MapMarkersGroupsFragment extends Fragment implements OsmAndCompassL updateAdapter(); } }); - View snackBarView = snackbar.getView(); - TextView tv = (TextView) snackBarView.findViewById(android.support.design.R.id.snackbar_action); - tv.setTextColor(ContextCompat.getColor(mapActivity, R.color.color_dialog_buttons_dark)); + AndroidUtils.setSnackbarTextColor(snackbar, R.color.color_dialog_buttons_dark); snackbar.show(); } } diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHistoryFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHistoryFragment.java index 9aa7991009..eeeac8de39 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHistoryFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHistoryFragment.java @@ -19,8 +19,8 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; -import android.widget.TextView; +import net.osmand.AndroidUtils; import net.osmand.plus.MapMarkersHelper; import net.osmand.plus.MapMarkersHelper.MapMarker; import net.osmand.plus.OsmandApplication; @@ -169,9 +169,7 @@ public class MapMarkersHistoryFragment extends Fragment implements MapMarkersHel } } }); - View snackBarView = snackbar.getView(); - TextView tv = (TextView) snackBarView.findViewById(android.support.design.R.id.snackbar_action); - tv.setTextColor(ContextCompat.getColor(mapActivity, R.color.color_dialog_buttons_dark)); + AndroidUtils.setSnackbarTextColor(snackbar, R.color.color_dialog_buttons_dark); snackbar.show(); } } diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java index 3d4789ba55..d6d51129b2 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java @@ -9,8 +9,8 @@ import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; -import android.widget.TextView; +import net.osmand.AndroidUtils; import net.osmand.data.LatLon; import net.osmand.plus.IconsCache; import net.osmand.plus.MapMarkersHelper; @@ -184,9 +184,7 @@ public class MapMarkersActiveAdapter extends RecyclerView.Adapter