Move split interval screen to dialog fragment
This commit is contained in:
parent
1a6dc4efbc
commit
dd292b3688
3 changed files with 139 additions and 95 deletions
|
@ -1,86 +1,115 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_height="match_parent"
|
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
android:layout_width="match_parent"
|
||||||
android:orientation="vertical">
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
<ListView
|
<android.support.v7.widget.Toolbar
|
||||||
android:id="@android:id/list"
|
android:id="@+id/split_interval_toolbar"
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_marginLeft="0dp"
|
|
||||||
android:layout_marginRight="0dp"
|
|
||||||
android:layout_marginTop="0dp"/>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/header_layout"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="@dimen/dashboard_map_toolbar"
|
||||||
android:orientation="vertical">
|
android:background="@color/osmand_orange"
|
||||||
|
android:minHeight="@dimen/dashboard_map_toolbar"
|
||||||
|
android:theme="?attr/toolbar_theme"
|
||||||
|
app:contentInsetLeft="54dp"
|
||||||
|
app:contentInsetStart="54dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:maxLines="1"
|
||||||
|
tools:text="2017-02-16"
|
||||||
|
android:textColor="@color/color_white"
|
||||||
|
android:textSize="@dimen/default_list_text_size_large"/>
|
||||||
|
|
||||||
|
</android.support.v7.widget.Toolbar>
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<ListView
|
||||||
|
android:id="@+id/list"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginLeft="0dp"
|
||||||
|
android:layout_marginRight="0dp"
|
||||||
|
android:layout_marginTop="0dp"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:orientation="horizontal"
|
android:id="@+id/header_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="48dp"
|
android:layout_height="wrap_content"
|
||||||
android:background="?attr/bg_color"
|
android:orientation="vertical">
|
||||||
android:paddingLeft="16dp"
|
|
||||||
android:paddingRight="16dp">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/header_split_image"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
tools:src="@drawable/ic_action_split_interval"
|
|
||||||
android:layout_marginBottom="12dp"
|
|
||||||
android:layout_marginTop="12dp"
|
|
||||||
android:layout_marginRight="16dp"/>
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/split_interval_view"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="48dp"
|
||||||
android:background="?attr/selectableItemBackground">
|
android:background="?attr/bg_color"
|
||||||
|
android:orientation="horizontal"
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
android:paddingLeft="16dp"
|
||||||
android:id="@+id/split_interval_title"
|
android:paddingRight="16dp">
|
||||||
android:background="@null"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textColor="?android:attr/textColorPrimary"
|
|
||||||
osmand:typeface="@string/font_roboto_medium"
|
|
||||||
android:textSize="@dimen/default_desc_text_size"
|
|
||||||
android:text="Split interval:"/>
|
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
|
||||||
android:id="@+id/split_interval_text"
|
|
||||||
android:background="@null"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:gravity="right"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textColor="?android:attr/textColorPrimary"
|
|
||||||
osmand:typeface="@string/font_roboto_medium"
|
|
||||||
android:textSize="@dimen/default_desc_text_size"
|
|
||||||
tools:text="10 km"/>
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/split_interval_arrow"
|
android:id="@+id/header_split_image"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:src="@drawable/ic_action_arrow_drop_down"/>
|
android:layout_marginBottom="12dp"
|
||||||
|
android:layout_marginRight="16dp"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
tools:src="@drawable/ic_action_split_interval"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/split_interval_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="?attr/selectableItemBackground">
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:id="@+id/split_interval_title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:background="@null"
|
||||||
|
android:text="Split interval:"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
|
osmand:typeface="@string/font_roboto_medium"/>
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:id="@+id/split_interval_text"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="@null"
|
||||||
|
android:gravity="right"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
|
tools:text="10 km"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/split_interval_arrow"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:src="@drawable/ic_action_arrow_drop_down"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<include layout="@layout/card_bottom_divider"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<include layout="@layout/card_bottom_divider"/>
|
</FrameLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</FrameLayout>
|
|
|
@ -7,7 +7,9 @@ import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.v4.app.DialogFragment;
|
||||||
import android.support.v7.widget.ListPopupWindow;
|
import android.support.v7.widget.ListPopupWindow;
|
||||||
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -32,9 +34,9 @@ import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
||||||
import net.osmand.plus.IconsCache;
|
import net.osmand.plus.IconsCache;
|
||||||
import net.osmand.plus.OsmAndFormatter;
|
import net.osmand.plus.OsmAndFormatter;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.TrackActivity;
|
import net.osmand.plus.activities.TrackActivity;
|
||||||
import net.osmand.plus.base.OsmAndListFragment;
|
|
||||||
import net.osmand.plus.helpers.FontCache;
|
import net.osmand.plus.helpers.FontCache;
|
||||||
import net.osmand.util.Algorithms;
|
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;
|
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";
|
public final static String TAG = "SPLIT_SEGMENT_FRAGMENT";
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
|
@ -66,25 +68,22 @@ public class SplitSegmentFragment extends OsmAndListFragment {
|
||||||
private int minMaxSpeedLayoutWidth;
|
private int minMaxSpeedLayoutWidth;
|
||||||
private Paint minMaxSpeedPaint;
|
private Paint minMaxSpeedPaint;
|
||||||
private Rect minMaxSpeedTextBounds;
|
private Rect minMaxSpeedTextBounds;
|
||||||
|
private ListView listView;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
app = getMyApplication();
|
app = getMyApplication();
|
||||||
ic = app.getIconsCache();
|
ic = app.getIconsCache();
|
||||||
}
|
boolean isLightTheme = app.getSettings().OSMAND_THEME.get() == OsmandSettings.OSMAND_LIGHT_THEME;
|
||||||
|
int themeId = isLightTheme ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme;
|
||||||
@Override
|
setStyle(STYLE_NO_FRAME, themeId);
|
||||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
|
||||||
super.onViewCreated(view, savedInstanceState);
|
|
||||||
updateContent();
|
|
||||||
// Obsolete: updateHeader();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityCreated(Bundle savedInstanceState) {
|
public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
super.onActivityCreated(savedInstanceState);
|
super.onActivityCreated(savedInstanceState);
|
||||||
getListView().setBackgroundColor(getResources().getColor(
|
listView.setBackgroundColor(getResources().getColor(
|
||||||
getMyApplication().getSettings().isLightContent() ? R.color.ctx_menu_info_view_bg_light
|
getMyApplication().getSettings().isLightContent() ? R.color.ctx_menu_info_view_bg_light
|
||||||
: R.color.ctx_menu_info_view_bg_dark));
|
: R.color.ctx_menu_info_view_bg_dark));
|
||||||
getTrackActivity().onAttachFragment(this);
|
getTrackActivity().onAttachFragment(this);
|
||||||
|
@ -96,15 +95,8 @@ public class SplitSegmentFragment extends OsmAndListFragment {
|
||||||
getTrackActivity().getClearToolbar(false);
|
getTrackActivity().getClearToolbar(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ArrayAdapter<?> getAdapter() {
|
|
||||||
return adapter;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
setHasOptionsMenu(true);
|
|
||||||
|
|
||||||
minMaxSpeedPaint = new Paint();
|
minMaxSpeedPaint = new Paint();
|
||||||
minMaxSpeedPaint.setTextSize(getResources().getDimension(R.dimen.default_split_segments_data));
|
minMaxSpeedPaint.setTextSize(getResources().getDimension(R.dimen.default_split_segments_data));
|
||||||
minMaxSpeedPaint.setTypeface(FontCache.getFont(getContext(), "fonts/Roboto-Medium.ttf"));
|
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 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.setDivider(null);
|
||||||
listView.setDividerHeight(0);
|
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.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));
|
listView.addFooterView(getActivity().getLayoutInflater().inflate(R.layout.list_shadow_footer, null, false));
|
||||||
|
|
||||||
setListAdapter(adapter);
|
|
||||||
|
|
||||||
listView.setOnScrollListener(new AbsListView.OnScrollListener() {
|
listView.setOnScrollListener(new AbsListView.OnScrollListener() {
|
||||||
int previousYPos = -1;
|
int previousYPos = -1;
|
||||||
|
|
||||||
|
@ -159,9 +158,17 @@ public class SplitSegmentFragment extends OsmAndListFragment {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
listView.setAdapter(adapter);
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||||
|
super.onViewCreated(view, savedInstanceState);
|
||||||
|
updateContent();
|
||||||
|
}
|
||||||
|
|
||||||
private void updateHeader() {
|
private void updateHeader() {
|
||||||
final View splitIntervalView = headerView.findViewById(R.id.split_interval_view);
|
final View splitIntervalView = headerView.findViewById(R.id.split_interval_view);
|
||||||
|
|
||||||
|
@ -213,9 +220,8 @@ public class SplitSegmentFragment extends OsmAndListFragment {
|
||||||
adapter.add(overviewSegments);
|
adapter.add(overviewSegments);
|
||||||
List<GpxDisplayItem> splitSegments = getSplitSegments();
|
List<GpxDisplayItem> splitSegments = getSplitSegments();
|
||||||
adapter.addAll(splitSegments);
|
adapter.addAll(splitSegments);
|
||||||
// Obsolete: adapter.setNotifyOnChange(true);
|
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
getListView().setSelection(0);
|
listView.setSelection(0);
|
||||||
headerView.setTranslationY(0);
|
headerView.setTranslationY(0);
|
||||||
updateHeader();
|
updateHeader();
|
||||||
}
|
}
|
||||||
|
@ -687,4 +693,18 @@ public class SplitSegmentFragment extends OsmAndListFragment {
|
||||||
return null;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1773,12 +1773,7 @@ public class TrackSegmentFragment extends OsmAndListFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
void openSplitIntervalScreen() {
|
void openSplitIntervalScreen() {
|
||||||
getTrackActivity().getSupportFragmentManager()
|
SplitSegmentFragment.showInstance(getTrackActivity());
|
||||||
.beginTransaction()
|
|
||||||
.replace(R.id.track_activity_layout, new SplitSegmentFragment())
|
|
||||||
.addToBackStack(SplitSegmentFragment.TAG)
|
|
||||||
.commit();
|
|
||||||
getTrackActivity().getSlidingTabLayout().setVisibility(View.GONE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SaveGpxAsyncTask extends AsyncTask<Void, Void, Void> {
|
private class SaveGpxAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||||
|
|
Loading…
Reference in a new issue