use of net.osmand.plus.settings.backend.OsmAndAppCustomization in project Osmand by osmandapp.
the class DashTrackFragment method initView.
@Override
public View initView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = getActivity().getLayoutInflater().inflate(R.layout.dash_common_fragment, container, false);
TextView header = (TextView) view.findViewById(R.id.fav_text);
header.setText(TITLE_ID);
(view.findViewById(R.id.show_all)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Activity activity = getActivity();
OsmAndAppCustomization appCustomization = getMyApplication().getAppCustomization();
final Intent favorites = new Intent(activity, appCustomization.getFavoritesActivity());
getMyApplication().getSettings().FAVORITES_TAB.set(FavoritesActivity.GPX_TAB);
favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
activity.startActivity(favorites);
closeDashboard();
}
});
return view;
}
use of net.osmand.plus.settings.backend.OsmAndAppCustomization in project Osmand by osmandapp.
the class ChooseRouteFragment method buildMenuButtons.
private void buildMenuButtons(@NonNull View view) {
OsmandApplication app = getMyApplication();
AppCompatImageView backButton = (AppCompatImageView) view.findViewById(R.id.back_button);
AppCompatImageButton backButtonFlow = (AppCompatImageButton) view.findViewById(R.id.back_button_flow);
OnClickListener backOnClick = new OnClickListener() {
@Override
public void onClick(View v) {
dismiss(true);
}
};
backButton.setOnClickListener(backOnClick);
backButtonFlow.setOnClickListener(backOnClick);
int navigationIconResId = AndroidUtils.getNavigationIconResId(getContext());
backButton.setImageResource(navigationIconResId);
backButtonFlow.setImageResource(navigationIconResId);
OnClickListener printOnClick = new OnClickListener() {
@Override
public void onClick(View v) {
print();
}
};
View printRoute = view.findViewById(R.id.print_route);
View printRouteFlow = view.findViewById(R.id.print_route_flow);
printRoute.setOnClickListener(printOnClick);
printRouteFlow.setOnClickListener(printOnClick);
View saveRoute = view.findViewById(R.id.save_as_gpx);
View saveRouteFlow = view.findViewById(R.id.save_as_gpx_flow);
OnClickListener saveOnClick = new OnClickListener() {
@Override
public void onClick(View v) {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
OsmandApplication app = mapActivity.getMyApplication();
GPXRouteParamsBuilder paramsBuilder = app.getRoutingHelper().getCurrentGPXRoute();
String fileName = null;
if (paramsBuilder != null && paramsBuilder.getFile() != null) {
GPXFile gpxFile = paramsBuilder.getFile();
if (!Algorithms.isEmpty(gpxFile.path)) {
fileName = Algorithms.getFileNameWithoutExtension(new File(gpxFile.path).getName());
} else if (!Algorithms.isEmpty(gpxFile.tracks)) {
fileName = gpxFile.tracks.get(0).name;
}
}
if (Algorithms.isEmpty(fileName)) {
String suggestedName = new SimpleDateFormat("EEE dd MMM yyyy", Locale.US).format(new Date());
fileName = FileUtils.createUniqueFileName(app, suggestedName, IndexConstants.GPX_INDEX_DIR, GPX_FILE_EXT);
}
SaveAsNewTrackBottomSheetDialogFragment.showInstance(mapActivity.getSupportFragmentManager(), ChooseRouteFragment.this, null, fileName, null, false, true);
}
}
};
saveRoute.setOnClickListener(saveOnClick);
saveRouteFlow.setOnClickListener(saveOnClick);
ImageView shareRoute = (ImageView) view.findViewById(R.id.share_as_gpx);
ImageView shareRouteFlow = (ImageView) view.findViewById(R.id.share_as_gpx_flow);
Drawable shareIcon = getIcon(R.drawable.ic_action_gshare_dark, ColorUtilities.getSecondaryTextColorId(nightMode));
shareIcon = AndroidUtils.getDrawableForDirection(app, shareIcon);
shareRoute.setImageDrawable(shareIcon);
shareRouteFlow.setImageDrawable(shareIcon);
OnClickListener shareOnClick = new OnClickListener() {
@Override
public void onClick(View v) {
FragmentActivity activity = getActivity();
if (activity != null) {
OsmandApplication app = (OsmandApplication) activity.getApplication();
RoutingHelper routingHelper = app.getRoutingHelper();
final String trackName = new SimpleDateFormat("yyyy-MM-dd_HH-mm_EEE", Locale.US).format(new Date());
final GPXUtilities.GPXFile gpx = routingHelper.generateGPXFileWithRoute(trackName);
final Uri fileUri = AndroidUtils.getUriForFile(app, new File(gpx.path));
File dir = new File(app.getCacheDir(), "share");
if (!dir.exists()) {
dir.mkdir();
}
File dst = new File(dir, "route.gpx");
try {
FileWriter fw = new FileWriter(dst);
GPXUtilities.writeGpx(fw, gpx, null);
fw.close();
final Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(generateHtml(routingHelper.getRouteDirections(), routingHelper.getGeneralRouteInformation()).toString()));
sendIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.share_route_subject));
sendIntent.putExtra(Intent.EXTRA_STREAM, fileUri);
sendIntent.putExtra(Intent.EXTRA_STREAM, AndroidUtils.getUriForFile(app, dst));
sendIntent.setType("text/plain");
sendIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
AndroidUtils.startActivityIfSafe(activity, sendIntent);
} catch (IOException e) {
}
}
}
};
shareRoute.setOnClickListener(shareOnClick);
shareRouteFlow.setOnClickListener(shareOnClick);
OsmAndAppCustomization customization = app.getAppCustomization();
boolean featureEnabled = customization.isFeatureEnabled(NAVIGATION_ROUTE_DETAILS_OPTIONS_ID);
if (publicTransportMode || !featureEnabled) {
view.findViewById(R.id.toolbar_options).setVisibility(View.GONE);
}
if (publicTransportMode || !portrait || !featureEnabled) {
view.findViewById(R.id.toolbar_options_flow).setVisibility(View.GONE);
view.findViewById(R.id.toolbar_options_flow_bg).setVisibility(View.GONE);
}
}
use of net.osmand.plus.settings.backend.OsmAndAppCustomization in project Osmand by osmandapp.
the class MapRouteInfoMenu method updateApplicationModesOptions.
public void updateApplicationModesOptions() {
View mainView = getMainView();
if (mainView != null) {
AppCompatImageView foldButtonView = mainView.findViewById(R.id.fold_button);
foldButtonView.setImageResource(getCurrentMenuState() == MenuState.HEADER_ONLY ? R.drawable.ic_action_arrow_up : R.drawable.ic_action_arrow_down);
foldButtonView.setOnClickListener(v -> expandCollapse());
OsmAndAppCustomization customization = getApp().getAppCustomization();
View options = mainView.findViewById(R.id.app_modes_options);
options.setOnClickListener(v -> showProfileBottomSheetDialog());
AndroidUiHelper.updateVisibility(options, customization.isFeatureEnabled(NAVIGATION_APP_MODES_OPTIONS_ID));
}
}
use of net.osmand.plus.settings.backend.OsmAndAppCustomization in project Osmand by osmandapp.
the class MapRouteInfoMenu method updateOptionsButtons.
private void updateOptionsButtons() {
MapActivity mapActivity = getMapActivity();
final View mainView = getMainView();
if (mapActivity == null || mainView == null) {
return;
}
final OsmandApplication app = mapActivity.getMyApplication();
RoutingHelper routingHelper = app.getRoutingHelper();
final ApplicationMode applicationMode = routingHelper.getAppMode();
final RouteMenuAppModes mode = app.getRoutingOptionsHelper().getRouteMenuAppMode(applicationMode);
boolean isLayoutRTL = AndroidUtils.isLayoutRtl(app);
updateControlButtons(mapActivity, mainView);
LinearLayout optionsButton = mainView.findViewById(R.id.map_options_route_button);
OsmAndAppCustomization customization = app.getAppCustomization();
AndroidUiHelper.updateVisibility(optionsButton, customization.isFeatureEnabled(NAVIGATION_OPTIONS_MENU_ID));
TextView optionsTitle = mainView.findViewById(R.id.map_options_route_button_title);
ImageView optionsIcon = mainView.findViewById(R.id.map_options_route_button_icon);
setupButtonIcon(optionsIcon, R.drawable.ic_action_settings);
optionsButton.setOnClickListener(v -> clickRouteParams());
AndroidUtils.setBackground(app, optionsButton, nightMode, isLayoutRTL ? R.drawable.route_info_trans_gradient_left_light : R.drawable.route_info_trans_gradient_light, isLayoutRTL ? R.drawable.route_info_trans_gradient_left_dark : R.drawable.route_info_trans_gradient_dark);
HorizontalScrollView scrollView = mainView.findViewById(R.id.route_options_scroll_container);
scrollView.setVerticalScrollBarEnabled(false);
scrollView.setHorizontalScrollBarEnabled(false);
LinearLayout optionsContainer = mainView.findViewById(R.id.route_options_container);
optionsContainer.removeAllViews();
if (mode == null) {
return;
}
createRoutingParametersButtons(mapActivity, mode, optionsContainer);
int endPadding = mapActivity.getResources().getDimensionPixelSize(R.dimen.action_bar_image_side_margin);
if (mode.parameters.size() > 2) {
optionsTitle.setVisibility(View.GONE);
} else {
optionsTitle.setVisibility(View.VISIBLE);
endPadding += AndroidUtils.getTextWidth(app.getResources().getDimensionPixelSize(R.dimen.text_button_text_size), app.getString(R.string.shared_string_options));
}
if (AndroidUtils.isLayoutRtl(app)) {
optionsContainer.setPadding(endPadding, optionsContainer.getPaddingTop(), optionsContainer.getPaddingRight(), optionsContainer.getPaddingBottom());
} else {
// LTR
optionsContainer.setPadding(optionsContainer.getPaddingLeft(), optionsContainer.getPaddingTop(), endPadding, optionsContainer.getPaddingBottom());
}
}
use of net.osmand.plus.settings.backend.OsmAndAppCustomization in project Osmand by osmandapp.
the class FavoritesActivity method openFavoritesGroup.
public static void openFavoritesGroup(Context context, String groupName) {
OsmAndAppCustomization appCustomization = ((OsmandApplication) context.getApplicationContext()).getAppCustomization();
Intent intent = new Intent(context, appCustomization.getFavoritesActivity());
Bundle b = new Bundle();
b.putInt(TAB_ID, FAV_TAB);
b.putString(FavoritesFragmentStateHolder.GROUP_NAME_TO_SHOW, groupName);
intent.putExtra(MapActivity.INTENT_PARAMS, b);
context.startActivity(intent);
}
Aggregations