use of android.graphics.Color in project mapbox-plugins-android by mapbox.
the class FillActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_annotation);
mapView = findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(mapboxMap -> mapboxMap.setStyle(Style.MAPBOX_STREETS, style -> {
findViewById(R.id.fabStyles).setOnClickListener(v -> mapboxMap.setStyle(Utils.INSTANCE.getNextStyle()));
mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(2));
fillManager = new FillManager(mapView, mapboxMap, style);
fillManager.addClickListener(fill -> {
Toast.makeText(FillActivity.this, String.format("Fill clicked %s with title: %s", fill.getId(), getTitleFromFill(fill)), Toast.LENGTH_SHORT).show();
return false;
});
fillManager.addLongClickListener(fill -> {
Toast.makeText(FillActivity.this, String.format("Fill long clicked %s with title: %s", fill.getId(), getTitleFromFill(fill)), Toast.LENGTH_SHORT).show();
return false;
});
// create a fixed fill
List<LatLng> innerLatLngs = new ArrayList<>();
innerLatLngs.add(new LatLng(-35.317366, -74.179687));
innerLatLngs.add(new LatLng(-35.317366, -30.761718));
innerLatLngs.add(new LatLng(4.740675, -30.761718));
innerLatLngs.add(new LatLng(4.740675, -74.179687));
innerLatLngs.add(new LatLng(-35.317366, -74.179687));
List<List<LatLng>> latLngs = new ArrayList<>();
latLngs.add(innerLatLngs);
FillOptions fillOptions = new FillOptions().withLatLngs(latLngs).withData(new JsonPrimitive("Foobar")).withFillColor(ColorUtils.colorToRgbaString(Color.RED));
fillManager.create(fillOptions);
// random add fills across the globe
List<FillOptions> fillOptionsList = new ArrayList<>();
for (int i = 0; i < 3; i++) {
int color = Color.argb(255, random.nextInt(256), random.nextInt(256), random.nextInt(256));
fillOptionsList.add(new FillOptions().withLatLngs(createRandomLatLngs()).withFillColor(ColorUtils.colorToRgbaString(color)));
}
fillManager.create(fillOptionsList);
try {
fillManager.create(FeatureCollection.fromJson(Utils.INSTANCE.loadStringFromAssets(this, "annotations.json")));
} catch (IOException e) {
throw new RuntimeException("Unable to parse annotations.json");
}
}));
}
use of android.graphics.Color in project Phonograph by kabouzeid.
the class ChangelogDialog method onCreateDialog.
@SuppressLint("InflateParams")
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final View customView;
try {
customView = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_web_view, null);
} catch (InflateException e) {
e.printStackTrace();
return new MaterialDialog.Builder(getActivity()).title(android.R.string.dialog_alert_title).content("This device doesn't support web view, which is necessary to view the change log. It is missing a system component.").positiveText(android.R.string.ok).build();
}
MaterialDialog dialog = new MaterialDialog.Builder(getActivity()).title(R.string.changelog).customView(customView, false).positiveText(android.R.string.ok).showListener(dialog1 -> {
if (getActivity() != null)
setChangelogRead(getActivity());
}).build();
final WebView webView = customView.findViewById(R.id.web_view);
try {
// Load from phonograph-changelog.html in the assets folder
StringBuilder buf = new StringBuilder();
InputStream json = getActivity().getAssets().open("phonograph-changelog.html");
BufferedReader in = new BufferedReader(new InputStreamReader(json, "UTF-8"));
String str;
while ((str = in.readLine()) != null) buf.append(str);
in.close();
// Inject color values for WebView body background and links
final String backgroundColor = colorToCSS(ATHUtil.resolveColor(getActivity(), R.attr.md_background_color, Color.parseColor(ThemeSingleton.get().darkTheme ? "#424242" : "#ffffff")));
final String contentColor = colorToCSS(Color.parseColor(ThemeSingleton.get().darkTheme ? "#ffffff" : "#000000"));
final String changeLog = buf.toString().replace("{style-placeholder}", String.format("body { background-color: %s; color: %s; }", backgroundColor, contentColor)).replace("{link-color}", colorToCSS(ThemeSingleton.get().positiveColor.getDefaultColor())).replace("{link-color-active}", colorToCSS(ColorUtil.lightenColor(ThemeSingleton.get().positiveColor.getDefaultColor())));
webView.loadData(changeLog, "text/html", "UTF-8");
} catch (Throwable e) {
webView.loadData("<h1>Unable to load</h1><p>" + e.getLocalizedMessage() + "</p>", "text/html", "UTF-8");
}
return dialog;
}
Aggregations