Add action bar and persist split
This commit is contained in:
parent
dd292b3688
commit
91cfaa600c
4 changed files with 64 additions and 80 deletions
|
@ -11,21 +11,26 @@
|
||||||
android:id="@+id/split_interval_toolbar"
|
android:id="@+id/split_interval_toolbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/dashboard_map_toolbar"
|
android:layout_height="@dimen/dashboard_map_toolbar"
|
||||||
android:background="@color/osmand_orange"
|
|
||||||
android:minHeight="@dimen/dashboard_map_toolbar"
|
android:minHeight="@dimen/dashboard_map_toolbar"
|
||||||
android:theme="?attr/toolbar_theme"
|
android:theme="?attr/actionBarStyle"
|
||||||
app:contentInsetLeft="54dp"
|
app:contentInsetLeft="54dp"
|
||||||
app:contentInsetStart="54dp">
|
app:contentInsetStart="54dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:id="@+id/title"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
tools:text="2017-02-16"
|
tools:text="2017-02-16"/>
|
||||||
android:textColor="@color/color_white"
|
|
||||||
android:textSize="@dimen/default_list_text_size_large"/>
|
<ProgressBar
|
||||||
|
android:id="@+id/progress_bar"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:visibility="visible"
|
||||||
|
android:indeterminate="true"/>
|
||||||
|
|
||||||
</android.support.v7.widget.Toolbar>
|
</android.support.v7.widget.Toolbar>
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.measurementtool.NewGpxData;
|
import net.osmand.plus.measurementtool.NewGpxData;
|
||||||
import net.osmand.plus.myplaces.FavoritesActivity;
|
import net.osmand.plus.myplaces.FavoritesActivity;
|
||||||
import net.osmand.plus.myplaces.SplitSegmentFragment;
|
import net.osmand.plus.myplaces.SplitSegmentDialogFragment;
|
||||||
import net.osmand.plus.myplaces.TrackPointFragment;
|
import net.osmand.plus.myplaces.TrackPointFragment;
|
||||||
import net.osmand.plus.myplaces.TrackSegmentFragment;
|
import net.osmand.plus.myplaces.TrackSegmentFragment;
|
||||||
import net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint;
|
import net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint;
|
||||||
|
@ -61,10 +61,6 @@ public class TrackActivity extends TabActivity {
|
||||||
private boolean openPointsTab = false;
|
private boolean openPointsTab = false;
|
||||||
private boolean openTracksList = false;
|
private boolean openTracksList = false;
|
||||||
|
|
||||||
public PagerSlidingTabStrip getSlidingTabLayout() {
|
|
||||||
return slidingTabLayout;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle icicle) {
|
public void onCreate(Bundle icicle) {
|
||||||
this.app = getMyApplication();
|
this.app = getMyApplication();
|
||||||
|
@ -294,8 +290,8 @@ public class TrackActivity extends TabActivity {
|
||||||
Fragment frag = f.get();
|
Fragment frag = f.get();
|
||||||
if (frag instanceof TrackSegmentFragment) {
|
if (frag instanceof TrackSegmentFragment) {
|
||||||
((TrackSegmentFragment) frag).updateContent();
|
((TrackSegmentFragment) frag).updateContent();
|
||||||
} else if (frag instanceof SplitSegmentFragment) {
|
} else if (frag instanceof SplitSegmentDialogFragment) {
|
||||||
((SplitSegmentFragment) frag).reloadSplitFragment();
|
((SplitSegmentDialogFragment) frag).updateContent();
|
||||||
} else if (frag instanceof TrackPointFragment) {
|
} else if (frag instanceof TrackPointFragment) {
|
||||||
((TrackPointFragment) frag).setContent();
|
((TrackPointFragment) frag).setContent();
|
||||||
}
|
}
|
||||||
|
@ -348,23 +344,6 @@ public class TrackActivity extends TabActivity {
|
||||||
int itemId = item.getItemId();
|
int itemId = item.getItemId();
|
||||||
switch (itemId) {
|
switch (itemId) {
|
||||||
case android.R.id.home:
|
case android.R.id.home:
|
||||||
int backStackEntriesCount = getSupportFragmentManager().getBackStackEntryCount();
|
|
||||||
if (backStackEntriesCount > 0) {
|
|
||||||
FragmentManager.BackStackEntry backStackEntry = getSupportFragmentManager().getBackStackEntryAt(getSupportFragmentManager().getBackStackEntryCount() - 1);
|
|
||||||
if (backStackEntry.getName().equals(SplitSegmentFragment.TAG)) {
|
|
||||||
for (WeakReference<Fragment> f : fragList) {
|
|
||||||
Fragment frag = f.get();
|
|
||||||
if (frag instanceof TrackSegmentFragment) {
|
|
||||||
((TrackSegmentFragment) frag).updateSplitView();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
getSupportFragmentManager().popBackStack();
|
|
||||||
if (isHavingWayPoints() || isHavingRoutePoints()) {
|
|
||||||
getSlidingTabLayout().setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (getIntent().hasExtra(MapActivity.INTENT_KEY_PARENT_MAP_ACTIVITY) || openTracksList) {
|
if (getIntent().hasExtra(MapActivity.INTENT_KEY_PARENT_MAP_ACTIVITY) || openTracksList) {
|
||||||
OsmAndAppCustomization appCustomization = getMyApplication().getAppCustomization();
|
OsmAndAppCustomization appCustomization = getMyApplication().getAppCustomization();
|
||||||
final Intent favorites = new Intent(this, appCustomization.getFavoritesActivity());
|
final Intent favorites = new Intent(this, appCustomization.getFavoritesActivity());
|
||||||
|
@ -379,25 +358,17 @@ public class TrackActivity extends TabActivity {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void updateSplitView() {
|
||||||
public void onBackPressed() {
|
for (WeakReference<Fragment> f : fragList) {
|
||||||
int backStackEntriesCount = getSupportFragmentManager().getBackStackEntryCount();
|
Fragment frag = f.get();
|
||||||
if (backStackEntriesCount > 0) {
|
if (frag instanceof TrackSegmentFragment) {
|
||||||
FragmentManager.BackStackEntry backStackEntry = getSupportFragmentManager().getBackStackEntryAt(getSupportFragmentManager().getBackStackEntryCount() - 1);
|
((TrackSegmentFragment) frag).updateSplitView();
|
||||||
if (backStackEntry.getName().equals(SplitSegmentFragment.TAG)) {
|
|
||||||
for (WeakReference<Fragment> f : fragList) {
|
|
||||||
Fragment frag = f.get();
|
|
||||||
if (frag instanceof TrackSegmentFragment) {
|
|
||||||
((TrackSegmentFragment) frag).updateSplitView();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
getSupportFragmentManager().popBackStack();
|
|
||||||
if (isHavingWayPoints() || isHavingRoutePoints()) {
|
|
||||||
getSlidingTabLayout().setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
if (openTracksList) {
|
if (openTracksList) {
|
||||||
OsmAndAppCustomization appCustomization = getMyApplication().getAppCustomization();
|
OsmAndAppCustomization appCustomization = getMyApplication().getAppCustomization();
|
||||||
final Intent favorites = new Intent(this, appCustomization.getFavoritesActivity());
|
final Intent favorites = new Intent(this, appCustomization.getFavoritesActivity());
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package net.osmand.plus.myplaces;
|
package net.osmand.plus.myplaces;
|
||||||
|
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
|
@ -8,13 +9,12 @@ 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.v4.app.DialogFragment;
|
||||||
|
import android.support.v7.app.ActionBar;
|
||||||
import android.support.v7.widget.ListPopupWindow;
|
import android.support.v7.widget.ListPopupWindow;
|
||||||
import android.support.v7.widget.Toolbar;
|
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;
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuInflater;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AbsListView;
|
import android.widget.AbsListView;
|
||||||
|
@ -22,6 +22,7 @@ import android.widget.AdapterView;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
|
@ -51,9 +52,9 @@ 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 DialogFragment {
|
public class SplitSegmentDialogFragment extends DialogFragment {
|
||||||
|
|
||||||
public final static String TAG = "SPLIT_SEGMENT_FRAGMENT";
|
public final static String TAG = "SPLIT_SEGMENT_DIALOG_FRAGMENT";
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
|
|
||||||
private SplitSegmentsAdapter adapter;
|
private SplitSegmentsAdapter adapter;
|
||||||
|
@ -69,6 +70,7 @@ public class SplitSegmentFragment extends DialogFragment {
|
||||||
private Paint minMaxSpeedPaint;
|
private Paint minMaxSpeedPaint;
|
||||||
private Rect minMaxSpeedTextBounds;
|
private Rect minMaxSpeedTextBounds;
|
||||||
private ListView listView;
|
private ListView listView;
|
||||||
|
private ProgressBar progressBar;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
@ -89,12 +91,6 @@ public class SplitSegmentFragment extends DialogFragment {
|
||||||
getTrackActivity().onAttachFragment(this);
|
getTrackActivity().onAttachFragment(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
|
||||||
menu.clear();
|
|
||||||
getTrackActivity().getClearToolbar(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
minMaxSpeedPaint = new Paint();
|
minMaxSpeedPaint = new Paint();
|
||||||
|
@ -106,6 +102,16 @@ public class SplitSegmentFragment extends DialogFragment {
|
||||||
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);
|
||||||
|
|
||||||
Toolbar toolbar = (Toolbar) view.findViewById(R.id.split_interval_toolbar);
|
Toolbar toolbar = (Toolbar) view.findViewById(R.id.split_interval_toolbar);
|
||||||
|
TextView titleTextView = (TextView) toolbar.findViewById(R.id.title);
|
||||||
|
if (app.getSettings().isLightContent()) {
|
||||||
|
titleTextView.setTextAppearance(getContext(), R.style.Widget_Styled_LightActionBarHeader);
|
||||||
|
} else {
|
||||||
|
titleTextView.setTextAppearance(getContext(), R.style.TextAppearance_AppCompat_Widget_ActionBar_Title);
|
||||||
|
}
|
||||||
|
ActionBar trackActivityActionBar = getTrackActivity().getSupportActionBar();
|
||||||
|
if (trackActivityActionBar != null) {
|
||||||
|
titleTextView.setText(trackActivityActionBar.getTitle());
|
||||||
|
}
|
||||||
toolbar.setNavigationIcon(getMyApplication().getIconsCache().getIcon(R.drawable.ic_arrow_back));
|
toolbar.setNavigationIcon(getMyApplication().getIconsCache().getIcon(R.drawable.ic_arrow_back));
|
||||||
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -114,6 +120,8 @@ public class SplitSegmentFragment extends DialogFragment {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
progressBar = view.findViewById(R.id.progress_bar);
|
||||||
|
|
||||||
listView = (ListView) view.findViewById(R.id.list);
|
listView = (ListView) view.findViewById(R.id.list);
|
||||||
listView.setDivider(null);
|
listView.setDivider(null);
|
||||||
listView.setDividerHeight(0);
|
listView.setDividerHeight(0);
|
||||||
|
@ -388,12 +396,16 @@ public class SplitSegmentFragment extends DialogFragment {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reloadSplitFragment() {
|
@Override
|
||||||
getFragmentManager()
|
public void dismiss() {
|
||||||
.beginTransaction()
|
getTrackActivity().updateSplitView();
|
||||||
.detach(this)
|
super.dismiss();
|
||||||
.attach(this)
|
}
|
||||||
.commit();
|
|
||||||
|
@Override
|
||||||
|
public void onCancel(DialogInterface dialog) {
|
||||||
|
getTrackActivity().updateSplitView();
|
||||||
|
super.onCancel(dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SplitSegmentsAdapter extends ArrayAdapter<GpxDisplayItem> {
|
private class SplitSegmentsAdapter extends ArrayAdapter<GpxDisplayItem> {
|
||||||
|
@ -652,41 +664,38 @@ public class SplitSegmentFragment extends DialogFragment {
|
||||||
private class SplitTrackAsyncTask extends AsyncTask<Void, Void, Void> {
|
private class SplitTrackAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||||
@Nullable
|
@Nullable
|
||||||
private final GpxSelectionHelper.SelectedGpxFile mSelectedGpxFile;
|
private final GpxSelectionHelper.SelectedGpxFile mSelectedGpxFile;
|
||||||
@NonNull private final TrackActivity mActivity;
|
|
||||||
|
|
||||||
private final List<GpxDisplayGroup> groups;
|
private final List<GpxDisplayGroup> groups;
|
||||||
|
|
||||||
SplitTrackAsyncTask(@Nullable GpxSelectionHelper.SelectedGpxFile selectedGpxFile, List<GpxDisplayGroup> groups) {
|
SplitTrackAsyncTask(@Nullable GpxSelectionHelper.SelectedGpxFile selectedGpxFile, List<GpxDisplayGroup> groups) {
|
||||||
mSelectedGpxFile = selectedGpxFile;
|
mSelectedGpxFile = selectedGpxFile;
|
||||||
mActivity = getTrackActivity();
|
|
||||||
this.groups = groups;
|
this.groups = groups;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void onPreExecute() {
|
||||||
|
progressBar.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
protected void onPostExecute(Void result) {
|
protected void onPostExecute(Void result) {
|
||||||
if (!mActivity.isFinishing()) {
|
progressBar.setVisibility(View.GONE);
|
||||||
mActivity.setSupportProgressBarIndeterminateVisibility(false);
|
|
||||||
}
|
|
||||||
if (mSelectedGpxFile != null) {
|
if (mSelectedGpxFile != null) {
|
||||||
List<GpxDisplayGroup> groups = getDisplayGroups();
|
List<GpxDisplayGroup> groups = getDisplayGroups();
|
||||||
mSelectedGpxFile.setDisplayGroups(groups);
|
mSelectedGpxFile.setDisplayGroups(groups);
|
||||||
}
|
}
|
||||||
updateContent();
|
if (getTrackActivity() != null) {
|
||||||
}
|
updateContent();
|
||||||
|
}
|
||||||
protected void onPreExecute() {
|
|
||||||
mActivity.setSupportProgressBarIndeterminateVisibility(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Void... params) {
|
protected Void doInBackground(Void... params) {
|
||||||
for (GpxDisplayGroup model : groups) {
|
for (GpxDisplayGroup model : groups) {
|
||||||
OsmandApplication application = mActivity.getMyApplication();
|
|
||||||
if (selectedSplitInterval == 0) {
|
if (selectedSplitInterval == 0) {
|
||||||
model.noSplit(application);
|
model.noSplit(app);
|
||||||
} else if (distanceSplit.get(selectedSplitInterval) > 0) {
|
} else if (distanceSplit.get(selectedSplitInterval) > 0) {
|
||||||
model.splitByDistance(application, distanceSplit.get(selectedSplitInterval));
|
model.splitByDistance(app, distanceSplit.get(selectedSplitInterval));
|
||||||
} else if (timeSplit.get(selectedSplitInterval) > 0) {
|
} else if (timeSplit.get(selectedSplitInterval) > 0) {
|
||||||
model.splitByTime(application, timeSplit.get(selectedSplitInterval));
|
model.splitByTime(app, timeSplit.get(selectedSplitInterval));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -700,7 +709,7 @@ public class SplitSegmentFragment extends DialogFragment {
|
||||||
|
|
||||||
public static boolean showInstance(TrackActivity trackActivity) {
|
public static boolean showInstance(TrackActivity trackActivity) {
|
||||||
try {
|
try {
|
||||||
SplitSegmentFragment fragment = new SplitSegmentFragment();
|
SplitSegmentDialogFragment fragment = new SplitSegmentDialogFragment();
|
||||||
fragment.show(trackActivity.getSupportFragmentManager(), TAG);
|
fragment.show(trackActivity.getSupportFragmentManager(), TAG);
|
||||||
return true;
|
return true;
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
|
@ -840,7 +840,6 @@ public class TrackSegmentFragment extends OsmAndListFragment {
|
||||||
for (GpxDisplayItem i : flatten(groups)) {
|
for (GpxDisplayItem i : flatten(groups)) {
|
||||||
adapter.add(i);
|
adapter.add(i);
|
||||||
}
|
}
|
||||||
// Obsolete: adapter.setNotifyOnChange(true);
|
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
if (getActivity() != null) {
|
if (getActivity() != null) {
|
||||||
updateHeader();
|
updateHeader();
|
||||||
|
@ -1773,7 +1772,7 @@ public class TrackSegmentFragment extends OsmAndListFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
void openSplitIntervalScreen() {
|
void openSplitIntervalScreen() {
|
||||||
SplitSegmentFragment.showInstance(getTrackActivity());
|
SplitSegmentDialogFragment.showInstance(getTrackActivity());
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SaveGpxAsyncTask extends AsyncTask<Void, Void, Void> {
|
private class SaveGpxAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||||
|
|
Loading…
Reference in a new issue