Search in sources :

Example 1 with OsmAndAppCustomization

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;
}
Also used : OsmAndAppCustomization(net.osmand.plus.settings.backend.OsmAndAppCustomization) FavoritesActivity(net.osmand.plus.myplaces.ui.FavoritesActivity) Activity(android.app.Activity) MapActivity(net.osmand.plus.activities.MapActivity) TextView(android.widget.TextView) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView)

Example 2 with OsmAndAppCustomization

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);
    }
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) FileWriter(java.io.FileWriter) Uri(android.net.Uri) GPXUtilities(net.osmand.GPXUtilities) AppCompatImageView(androidx.appcompat.widget.AppCompatImageView) ImageView(android.widget.ImageView) GPXFile(net.osmand.GPXUtilities.GPXFile) MapActivity(net.osmand.plus.activities.MapActivity) GPXRouteParamsBuilder(net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder) Drawable(android.graphics.drawable.Drawable) Intent(android.content.Intent) AppCompatImageButton(androidx.appcompat.widget.AppCompatImageButton) TransportRoutingHelper(net.osmand.plus.routing.TransportRoutingHelper) RoutingHelper(net.osmand.plus.routing.RoutingHelper) IOException(java.io.IOException) AppCompatImageView(androidx.appcompat.widget.AppCompatImageView) AppCompatImageView(androidx.appcompat.widget.AppCompatImageView) ImageView(android.widget.ImageView) View(android.view.View) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) Date(java.util.Date) FragmentActivity(androidx.fragment.app.FragmentActivity) OsmAndAppCustomization(net.osmand.plus.settings.backend.OsmAndAppCustomization) OnClickListener(android.view.View.OnClickListener) GPXFile(net.osmand.GPXUtilities.GPXFile) GPXFile(net.osmand.GPXUtilities.GPXFile) File(java.io.File) SimpleDateFormat(java.text.SimpleDateFormat)

Example 3 with OsmAndAppCustomization

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));
    }
}
Also used : OsmAndAppCustomization(net.osmand.plus.settings.backend.OsmAndAppCustomization) ImageView(android.widget.ImageView) HorizontalScrollView(android.widget.HorizontalScrollView) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) AppCompatImageView(androidx.appcompat.widget.AppCompatImageView) View(android.view.View) TextView(android.widget.TextView) AppCompatImageView(androidx.appcompat.widget.AppCompatImageView)

Example 4 with OsmAndAppCustomization

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());
    }
}
Also used : RouteMenuAppModes(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.RouteMenuAppModes) OsmandApplication(net.osmand.plus.OsmandApplication) RoutingHelper(net.osmand.plus.routing.RoutingHelper) TransportRoutingHelper(net.osmand.plus.routing.TransportRoutingHelper) ApplicationMode(net.osmand.plus.settings.backend.ApplicationMode) ImageView(android.widget.ImageView) HorizontalScrollView(android.widget.HorizontalScrollView) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) AppCompatImageView(androidx.appcompat.widget.AppCompatImageView) View(android.view.View) TextView(android.widget.TextView) FavouritePoint(net.osmand.data.FavouritePoint) TargetPoint(net.osmand.plus.helpers.TargetPointsHelper.TargetPoint) OsmAndAppCustomization(net.osmand.plus.settings.backend.OsmAndAppCustomization) TextView(android.widget.TextView) ImageView(android.widget.ImageView) AppCompatImageView(androidx.appcompat.widget.AppCompatImageView) HorizontalScrollView(android.widget.HorizontalScrollView) LinearLayout(android.widget.LinearLayout) MapActivity(net.osmand.plus.activities.MapActivity)

Example 5 with OsmAndAppCustomization

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);
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) OsmAndAppCustomization(net.osmand.plus.settings.backend.OsmAndAppCustomization) Bundle(android.os.Bundle) Intent(android.content.Intent)

Aggregations

OsmAndAppCustomization (net.osmand.plus.settings.backend.OsmAndAppCustomization)15 Intent (android.content.Intent)9 Bundle (android.os.Bundle)5 View (android.view.View)4 ImageView (android.widget.ImageView)4 FragmentManager (androidx.fragment.app.FragmentManager)4 OsmandApplication (net.osmand.plus.OsmandApplication)4 MapActivity (net.osmand.plus.activities.MapActivity)4 OsmandMapTileView (net.osmand.plus.views.OsmandMapTileView)4 SpannableString (android.text.SpannableString)3 TextView (android.widget.TextView)3 AppCompatImageView (androidx.appcompat.widget.AppCompatImageView)3 RoutingHelper (net.osmand.plus.routing.RoutingHelper)3 Activity (android.app.Activity)2 HorizontalScrollView (android.widget.HorizontalScrollView)2 FragmentActivity (androidx.fragment.app.FragmentActivity)2 File (java.io.File)2 TransportRoutingHelper (net.osmand.plus.routing.TransportRoutingHelper)2 ApplicationMode (net.osmand.plus.settings.backend.ApplicationMode)2 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)1