use of com.mapbox.pluginscalebar.ScaleBarOptions in project mapbox-plugins-android by mapbox.
the class ScaleBarTest method testScaleBarColor.
@Test
public void testScaleBarColor() {
validateTestSetup();
setupScaleBar();
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertEquals(ContextCompat.getColor(activity, android.R.color.black), scaleBarWidget.getTextColor());
assertEquals(ContextCompat.getColor(activity, android.R.color.black), scaleBarWidget.getPrimaryColor());
assertEquals(ContextCompat.getColor(activity, android.R.color.white), scaleBarWidget.getSecondaryColor());
int textColor = R.color.colorAccent;
int colorPrimary = R.color.colorPrimary;
int colorSecondary = R.color.colorPrimaryDark;
ScaleBarOptions option = new ScaleBarOptions(activity);
option.setTextColor(textColor);
option.setPrimaryColor(colorPrimary);
option.setSecondaryColor(colorSecondary);
scaleBarWidget = scaleBarPlugin.create(option);
assertNotNull(scaleBarWidget);
assertEquals(ContextCompat.getColor(activity, textColor), scaleBarWidget.getTextColor());
assertEquals(ContextCompat.getColor(activity, colorPrimary), scaleBarWidget.getPrimaryColor());
assertEquals(ContextCompat.getColor(activity, colorSecondary), scaleBarWidget.getSecondaryColor());
});
}
use of com.mapbox.pluginscalebar.ScaleBarOptions in project mapbox-plugins-android by mapbox.
the class ScaleBarTest method testRefreshInterval.
@Test
public void testRefreshInterval() {
validateTestSetup();
setupScaleBar();
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertEquals(ScaleBarOptions.REFRESH_INTERVAL_DEFAULT, scaleBarWidget.getRefreshInterval(), 0);
ScaleBarOptions option = new ScaleBarOptions(activity);
option.setRefreshInterval(1000);
scaleBarWidget = scaleBarPlugin.create(option);
assertNotNull(scaleBarWidget);
assertEquals(1000, scaleBarWidget.getRefreshInterval(), 0);
});
}
use of com.mapbox.pluginscalebar.ScaleBarOptions in project mapbox-plugins-android by mapbox.
the class ScaleBarTest method testMetrics.
@Test
public void testMetrics() {
validateTestSetup();
setupScaleBar();
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertEquals(ScaleBarOptions.LocaleUnitResolver.isMetricSystem(), scaleBarWidget.isMetricUnit());
ScaleBarOptions option = new ScaleBarOptions(activity);
option.setMetricUnit(true);
scaleBarWidget = scaleBarPlugin.create(option);
assertNotNull(scaleBarWidget);
assertTrue(scaleBarWidget.isMetricUnit());
option = new ScaleBarOptions(activity);
option.setMetricUnit(false);
scaleBarWidget = scaleBarPlugin.create(option);
assertNotNull(scaleBarWidget);
assertFalse(scaleBarWidget.isMetricUnit());
});
}
use of com.mapbox.pluginscalebar.ScaleBarOptions in project mapbox-plugins-android by mapbox.
the class ScaleBarTest method testBorderWidth.
@Test
public void testBorderWidth() {
validateTestSetup();
setupScaleBar();
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertEquals(activity.getResources().getDimension(R.dimen.mapbox_scale_bar_border_width), scaleBarWidget.getBorderWidth(), 0);
ScaleBarOptions option = new ScaleBarOptions(activity);
option.setBorderWidth(R.dimen.fab_margin);
scaleBarWidget = scaleBarPlugin.create(option);
assertNotNull(scaleBarWidget);
assertEquals(activity.getResources().getDimension(R.dimen.fab_margin), scaleBarWidget.getBorderWidth(), 0);
option = new ScaleBarOptions(activity);
option.setBorderWidth(100f);
scaleBarWidget = scaleBarPlugin.create(option);
assertNotNull(scaleBarWidget);
assertEquals(100f, scaleBarWidget.getBorderWidth(), 0);
});
}
use of com.mapbox.pluginscalebar.ScaleBarOptions in project apps-android-commons by commons-app.
the class NearbyParentFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull final View view, @Nullable final Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
isDarkTheme = systemThemeUtils.isDeviceInNightMode();
if (Utils.isMonumentsEnabled(new Date())) {
rlContainerWLMMonthMessage.setVisibility(View.VISIBLE);
} else {
rlContainerWLMMonthMessage.setVisibility(View.GONE);
}
cameraMoveListener = () -> presenter.onCameraMove(mapBox.getCameraPosition().target);
addCheckBoxCallback();
presenter.attachView(this);
isPermissionDenied = false;
recenterToUserLocation = false;
initRvNearbyList();
initThemePreferences();
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(mapBoxMap -> {
mapBox = mapBoxMap;
initViews();
presenter.setActionListeners(applicationKvStore);
initNearbyFilter();
mapBoxMap.setStyle(isDarkTheme ? Style.DARK : Style.OUTDOORS, style -> {
final UiSettings uiSettings = mapBoxMap.getUiSettings();
uiSettings.setCompassGravity(Gravity.BOTTOM | Gravity.LEFT);
uiSettings.setCompassMargins(12, 0, 0, 24);
uiSettings.setLogoEnabled(false);
uiSettings.setAttributionEnabled(false);
uiSettings.setRotateGesturesEnabled(false);
isMapBoxReady = true;
if (nearbyParentFragmentInstanceReadyCallback != null) {
nearbyParentFragmentInstanceReadyCallback.onReady();
}
performMapReadyActions();
final CameraPosition cameraPosition;
if (applicationKvStore.getString("LastLocation") != null) {
// Checking for last searched location
String[] locationLatLng = applicationKvStore.getString("LastLocation").split(",");
cameraPosition = new CameraPosition.Builder().target(new LatLng(Double.valueOf(locationLatLng[0]), Double.valueOf(locationLatLng[1]))).zoom(ZOOM_LEVEL).build();
} else {
cameraPosition = new CameraPosition.Builder().target(new LatLng(51.50550, -0.07520)).zoom(ZOOM_OUT).build();
}
mapBoxMap.setCameraPosition(cameraPosition);
final ScaleBarPlugin scaleBarPlugin = new ScaleBarPlugin(mapView, mapBoxMap);
final int color = isDarkTheme ? R.color.bottom_bar_light : R.color.bottom_bar_dark;
final ScaleBarOptions scaleBarOptions = new ScaleBarOptions(getContext()).setTextColor(color).setTextSize(R.dimen.description_text_size).setBarHeight(R.dimen.tiny_gap).setBorderWidth(R.dimen.miniscule_margin).setMarginTop(R.dimen.tiny_padding).setMarginLeft(R.dimen.tiny_padding).setTextBarMargin(R.dimen.tiny_padding);
scaleBarPlugin.create(scaleBarOptions);
onResume();
});
});
tvAttribution.setText(Html.fromHtml(getString(R.string.map_attribution)));
tvAttribution.setMovementMethod(LinkMovementMethod.getInstance());
btnAdvancedOptions.setOnClickListener(v -> {
searchView.clearFocus();
showHideAdvancedQueryFragment(true);
final AdvanceQueryFragment fragment = new AdvanceQueryFragment();
final Bundle bundle = new Bundle();
try {
bundle.putString("query", FileUtils.readFromResource("/queries/nearby_query.rq"));
} catch (IOException e) {
Timber.e(e);
}
fragment.setArguments(bundle);
fragment.callback = new Callback() {
@Override
public void close() {
showHideAdvancedQueryFragment(false);
}
@Override
public void reset() {
presenter.setAdvancedQuery(null);
presenter.updateMapAndList(LOCATION_SIGNIFICANTLY_CHANGED);
showHideAdvancedQueryFragment(false);
}
@Override
public void apply(@NotNull final String query) {
presenter.setAdvancedQuery(query);
presenter.updateMapAndList(CUSTOM_QUERY);
showHideAdvancedQueryFragment(false);
}
};
getChildFragmentManager().beginTransaction().replace(R.id.fl_container_nearby_children, fragment).commit();
});
}
Aggregations