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,13 +1,40 @@
|
|||
<?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"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/split_interval_toolbar"
|
||||
android:layout_width="match_parent"
|
||||
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">
|
||||
|
||||
<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="@android:id/list"
|
||||
android:id="@+id/list"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="0dp"
|
||||
|
@ -21,10 +48,10 @@
|
|||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:background="?attr/bg_color"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp">
|
||||
|
||||
|
@ -33,10 +60,10 @@
|
|||
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_marginRight="16dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginRight="16dp"/>
|
||||
tools:src="@drawable/ic_action_split_interval"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/split_interval_view"
|
||||
|
@ -46,26 +73,26 @@
|
|||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/split_interval_title"
|
||||
android:background="@null"
|
||||
android:layout_gravity="center_vertical"
|
||||
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"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
android:text="Split interval:"/>
|
||||
osmand:typeface="@string/font_roboto_medium"/>
|
||||
|
||||
<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:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:background="@null"
|
||||
android:gravity="right"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
tools:text="10 km"/>
|
||||
|
||||
<ImageView
|
||||
|
@ -83,4 +110,6 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -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();
|
||||
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<GpxDisplayItem> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<Void, Void, Void> {
|
||||
|
|
Loading…
Reference in a new issue