diff --git a/OsmAnd/res/layout/split_segments_layout.xml b/OsmAnd/res/layout/split_segments_layout.xml index 20fdb8abfe..e2975d8df6 100644 --- a/OsmAnd/res/layout/split_segments_layout.xml +++ b/OsmAnd/res/layout/split_segments_layout.xml @@ -1,86 +1,115 @@ - + - - - + android:layout_height="@dimen/dashboard_map_toolbar" + android:background="@color/osmand_orange" + android:minHeight="@dimen/dashboard_map_toolbar" + android:theme="?attr/toolbar_theme" + app:contentInsetLeft="54dp" + app:contentInsetStart="54dp"> + + + + + + + + - - + android:layout_height="wrap_content" + android:orientation="vertical"> - - - - + android:layout_height="48dp" + android:background="?attr/bg_color" + android:orientation="horizontal" + android:paddingLeft="16dp" + android:paddingRight="16dp"> + android:layout_marginBottom="12dp" + android:layout_marginRight="16dp" + android:layout_marginTop="12dp" + tools:src="@drawable/ic_action_split_interval"/> + + + + + + + + + + + + - + - - - \ No newline at end of file + \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/myplaces/SplitSegmentFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/SplitSegmentFragment.java index 9edec0db4a..716c8aee80 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/SplitSegmentFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/SplitSegmentFragment.java @@ -7,7 +7,9 @@ import android.os.AsyncTask; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.support.v4.app.DialogFragment; import android.support.v7.widget.ListPopupWindow; +import android.support.v7.widget.Toolbar; import android.util.DisplayMetrics; import android.view.Gravity; import android.view.LayoutInflater; @@ -32,9 +34,9 @@ import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem; import net.osmand.plus.IconsCache; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmandApplication; +import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.activities.TrackActivity; -import net.osmand.plus.base.OsmAndListFragment; import net.osmand.plus.helpers.FontCache; import net.osmand.util.Algorithms; @@ -49,7 +51,7 @@ import gnu.trove.list.array.TIntArrayList; import static net.osmand.plus.myplaces.TrackSegmentFragment.ARG_TO_FILTER_SHORT_TRACKS; -public class SplitSegmentFragment extends OsmAndListFragment { +public class SplitSegmentFragment extends DialogFragment { public final static String TAG = "SPLIT_SEGMENT_FRAGMENT"; private OsmandApplication app; @@ -66,25 +68,22 @@ public class SplitSegmentFragment extends OsmAndListFragment { private int minMaxSpeedLayoutWidth; private Paint minMaxSpeedPaint; private Rect minMaxSpeedTextBounds; + private ListView listView; @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); - app = getMyApplication(); + app = getMyApplication(); ic = app.getIconsCache(); - } - - @Override - public void onViewCreated(View view, Bundle savedInstanceState) { - super.onViewCreated(view, savedInstanceState); - updateContent(); - // Obsolete: updateHeader(); + boolean isLightTheme = app.getSettings().OSMAND_THEME.get() == OsmandSettings.OSMAND_LIGHT_THEME; + int themeId = isLightTheme ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme; + setStyle(STYLE_NO_FRAME, themeId); } @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); - getListView().setBackgroundColor(getResources().getColor( + listView.setBackgroundColor(getResources().getColor( getMyApplication().getSettings().isLightContent() ? R.color.ctx_menu_info_view_bg_light : R.color.ctx_menu_info_view_bg_dark)); getTrackActivity().onAttachFragment(this); @@ -96,15 +95,8 @@ public class SplitSegmentFragment extends OsmAndListFragment { getTrackActivity().getClearToolbar(false); } - @Override - public ArrayAdapter getAdapter() { - return adapter; - } - @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - setHasOptionsMenu(true); - minMaxSpeedPaint = new Paint(); minMaxSpeedPaint.setTextSize(getResources().getDimension(R.dimen.default_split_segments_data)); minMaxSpeedPaint.setTypeface(FontCache.getFont(getContext(), "fonts/Roboto-Medium.ttf")); @@ -113,7 +105,16 @@ public class SplitSegmentFragment extends OsmAndListFragment { final View view = getActivity().getLayoutInflater().inflate(R.layout.split_segments_layout, container, false); - final ListView listView = (ListView) view.findViewById(android.R.id.list); + Toolbar toolbar = (Toolbar) view.findViewById(R.id.split_interval_toolbar); + toolbar.setNavigationIcon(getMyApplication().getIconsCache().getIcon(R.drawable.ic_arrow_back)); + toolbar.setNavigationOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + dismiss(); + } + }); + + listView = (ListView) view.findViewById(R.id.list); listView.setDivider(null); listView.setDividerHeight(0); @@ -124,8 +125,6 @@ public class SplitSegmentFragment extends OsmAndListFragment { listView.addHeaderView(getActivity().getLayoutInflater().inflate(R.layout.gpx_split_segments_empty_header, null, false)); listView.addFooterView(getActivity().getLayoutInflater().inflate(R.layout.list_shadow_footer, null, false)); - setListAdapter(adapter); - listView.setOnScrollListener(new AbsListView.OnScrollListener() { int previousYPos = -1; @@ -159,9 +158,17 @@ public class SplitSegmentFragment extends OsmAndListFragment { } }); + listView.setAdapter(adapter); + return view; } + @Override + public void onViewCreated(View view, Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + updateContent(); + } + private void updateHeader() { final View splitIntervalView = headerView.findViewById(R.id.split_interval_view); @@ -213,9 +220,8 @@ public class SplitSegmentFragment extends OsmAndListFragment { adapter.add(overviewSegments); List splitSegments = getSplitSegments(); adapter.addAll(splitSegments); - // Obsolete: adapter.setNotifyOnChange(true); adapter.notifyDataSetChanged(); - getListView().setSelection(0); + listView.setSelection(0); headerView.setTranslationY(0); updateHeader(); } @@ -687,4 +693,18 @@ public class SplitSegmentFragment extends OsmAndListFragment { return null; } } + + private OsmandApplication getMyApplication() { + return (OsmandApplication) getActivity().getApplication(); + } + + public static boolean showInstance(TrackActivity trackActivity) { + try { + SplitSegmentFragment fragment = new SplitSegmentFragment(); + fragment.show(trackActivity.getSupportFragmentManager(), TAG); + return true; + } catch (RuntimeException e) { + return false; + } + } } diff --git a/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java index a84e07a802..7a4bfbeff2 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java @@ -1773,12 +1773,7 @@ public class TrackSegmentFragment extends OsmAndListFragment { } void openSplitIntervalScreen() { - getTrackActivity().getSupportFragmentManager() - .beginTransaction() - .replace(R.id.track_activity_layout, new SplitSegmentFragment()) - .addToBackStack(SplitSegmentFragment.TAG) - .commit(); - getTrackActivity().getSlidingTabLayout().setVisibility(View.GONE); + SplitSegmentFragment.showInstance(getTrackActivity()); } private class SaveGpxAsyncTask extends AsyncTask {