Search in sources :

Example 1 with OsmAndAppCustomization

use of net.osmand.plus.OsmAndAppCustomization in project Osmand by osmandapp.

the class TrackActivity method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int itemId = item.getItemId();
    switch(itemId) {
        case android.R.id.home:
            if (getIntent().hasExtra(MapActivity.INTENT_KEY_PARENT_MAP_ACTIVITY) || openTracksList) {
                OsmAndAppCustomization appCustomization = getMyApplication().getAppCustomization();
                final Intent favorites = new Intent(this, appCustomization.getFavoritesActivity());
                getMyApplication().getSettings().FAVORITES_TAB.set(FavoritesActivity.GPX_TAB);
                favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
                startActivity(favorites);
            }
            finish();
            return true;
    }
    return false;
}
Also used : OsmAndAppCustomization(net.osmand.plus.OsmAndAppCustomization) Intent(android.content.Intent) NewGpxPoint(net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint)

Example 2 with OsmAndAppCustomization

use of net.osmand.plus.OsmAndAppCustomization in project Osmand by osmandapp.

the class WptPtMenuBuilder method getCollapsableWaypointsView.

private CollapsableView getCollapsableWaypointsView(final Context context, boolean collapsed, @NonNull final GPXUtilities.GPXFile gpxFile, WptPt selectedPoint) {
    LinearLayout view = (LinearLayout) buildCollapsableContentView(context, collapsed, true);
    List<WptPt> points = gpxFile.getPoints();
    for (int i = 0; i < points.size() && i < 10; i++) {
        final WptPt point = points.get(i);
        boolean selected = selectedPoint != null && selectedPoint.equals(point);
        TextViewEx button = buildButtonInCollapsableView(context, selected, false);
        button.setText(point.name);
        if (!selected) {
            button.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    LatLon latLon = new LatLon(point.getLatitude(), point.getLongitude());
                    PointDescription pointDescription = new PointDescription(PointDescription.POINT_TYPE_WPT, point.name);
                    mapActivity.getContextMenu().show(latLon, pointDescription, point);
                }
            });
        }
        view.addView(button);
    }
    if (points.size() > 10) {
        TextViewEx button = buildButtonInCollapsableView(context, false, true);
        button.setText(context.getString(R.string.shared_string_show_all));
        button.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                OsmAndAppCustomization appCustomization = app.getAppCustomization();
                final Intent intent = new Intent(context, appCustomization.getTrackActivity());
                intent.putExtra(TrackActivity.TRACK_FILE_NAME, gpxFile.path);
                intent.putExtra(TrackActivity.OPEN_POINTS_TAB, true);
                intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
                context.startActivity(intent);
            }
        });
        view.addView(button);
    }
    return new CollapsableView(view, this, collapsed);
}
Also used : WptPt(net.osmand.plus.GPXUtilities.WptPt) Intent(android.content.Intent) View(android.view.View) LatLon(net.osmand.data.LatLon) TextViewEx(net.osmand.plus.widgets.TextViewEx) OsmAndAppCustomization(net.osmand.plus.OsmAndAppCustomization) PointDescription(net.osmand.data.PointDescription) LinearLayout(android.widget.LinearLayout)

Example 3 with OsmAndAppCustomization

use of net.osmand.plus.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.OsmAndAppCustomization) FavoritesActivity(net.osmand.plus.myplaces.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 4 with OsmAndAppCustomization

use of net.osmand.plus.OsmAndAppCustomization in project Osmand by osmandapp.

the class FavouritePointMenuBuilder method getCollapsableFavouritesView.

private CollapsableView getCollapsableFavouritesView(final Context context, boolean collapsed, @NonNull final FavoriteGroup group, FavouritePoint selectedPoint) {
    LinearLayout view = (LinearLayout) buildCollapsableContentView(context, collapsed, true);
    List<FavouritePoint> points = group.points;
    for (int i = 0; i < points.size() && i < 10; i++) {
        final FavouritePoint point = points.get(i);
        boolean selected = selectedPoint != null && selectedPoint.equals(point);
        TextViewEx button = buildButtonInCollapsableView(context, selected, false);
        String name = point.getName();
        button.setText(name);
        if (!selected) {
            button.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    LatLon latLon = new LatLon(point.getLatitude(), point.getLongitude());
                    PointDescription pointDescription = new PointDescription(PointDescription.POINT_TYPE_FAVORITE, point.getName());
                    mapActivity.getContextMenu().show(latLon, pointDescription, point);
                }
            });
        }
        view.addView(button);
    }
    if (points.size() > 10) {
        TextViewEx button = buildButtonInCollapsableView(context, false, true);
        button.setText(context.getString(R.string.shared_string_show_all));
        button.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                OsmAndAppCustomization appCustomization = app.getAppCustomization();
                final Intent intent = new Intent(context, appCustomization.getFavoritesActivity());
                intent.putExtra(FavoritesActivity.OPEN_FAVOURITES_TAB, true);
                intent.putExtra(FavoritesActivity.GROUP_NAME_TO_SHOW, group.name);
                intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
                context.startActivity(intent);
            }
        });
        view.addView(button);
    }
    return new CollapsableView(view, this, collapsed);
}
Also used : FavouritePoint(net.osmand.data.FavouritePoint) Intent(android.content.Intent) View(android.view.View) TextView(android.widget.TextView) FavouritePoint(net.osmand.data.FavouritePoint) LatLon(net.osmand.data.LatLon) TextViewEx(net.osmand.plus.widgets.TextViewEx) OsmAndAppCustomization(net.osmand.plus.OsmAndAppCustomization) PointDescription(net.osmand.data.PointDescription) LinearLayout(android.widget.LinearLayout)

Example 5 with OsmAndAppCustomization

use of net.osmand.plus.OsmAndAppCustomization in project Osmand by osmandapp.

the class DashBaseFragment method startFavoritesActivity.

protected void startFavoritesActivity(int tab) {
    Activity activity = getActivity();
    OsmAndAppCustomization appCustomization = getMyApplication().getAppCustomization();
    final Intent favorites = new Intent(activity, appCustomization.getFavoritesActivity());
    favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
    getMyApplication().getSettings().FAVORITES_TAB.set(tab);
    activity.startActivity(favorites);
}
Also used : OsmAndAppCustomization(net.osmand.plus.OsmAndAppCustomization) Activity(android.app.Activity) MapActivity(net.osmand.plus.activities.MapActivity) Intent(android.content.Intent)

Aggregations

Intent (android.content.Intent)7 OsmAndAppCustomization (net.osmand.plus.OsmAndAppCustomization)7 View (android.view.View)3 Activity (android.app.Activity)2 LinearLayout (android.widget.LinearLayout)2 TextView (android.widget.TextView)2 LatLon (net.osmand.data.LatLon)2 PointDescription (net.osmand.data.PointDescription)2 MapActivity (net.osmand.plus.activities.MapActivity)2 TextViewEx (net.osmand.plus.widgets.TextViewEx)2 CheckBoxPreference (android.preference.CheckBoxPreference)1 DialogPreference (android.preference.DialogPreference)1 Preference (android.preference.Preference)1 OnPreferenceClickListener (android.preference.Preference.OnPreferenceClickListener)1 PreferenceScreen (android.preference.PreferenceScreen)1 ImageView (android.widget.ImageView)1 FavouritePoint (net.osmand.data.FavouritePoint)1 WptPt (net.osmand.plus.GPXUtilities.WptPt)1 OsmandApplication (net.osmand.plus.OsmandApplication)1 FavoritesActivity (net.osmand.plus.myplaces.FavoritesActivity)1