Refactored gpx track fragment. Added custom shadow to gpx track nav bar.

This commit is contained in:
Alexey Kulish 2018-05-10 15:54:57 +03:00
parent 8e5985a77c
commit 49e99b4914
9 changed files with 671 additions and 558 deletions

View file

@ -17,11 +17,18 @@
android:layout_height="0dp"
android:layout_weight="1">
<android.support.v4.view.ViewPager
<net.osmand.plus.LockableViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:src="?attr/bottom_nav_shadow"
android:scaleType="fitXY"/>
</FrameLayout>
<android.support.design.widget.BottomNavigationView
@ -30,6 +37,7 @@
android:layout_height="wrap_content"
android:background="?attr/wikivoyage_card_bg_color"
android:visibility="gone"
app:elevation="0dp"
tools:visibility="visible"
app:itemBackground="?attr/wikivoyage_card_bg_color"
app:menu="@menu/track_bottom_navigation"

View file

@ -92,6 +92,7 @@
<attr name="wikivoyage_primary_btn_bg" format="reference"/>
<attr name="purchase_dialog_shadow_btn_bg" format="reference"/>
<attr name="bottom_nav_shadow" format="reference"/>
<attr name="purchase_dialog_active_card_bg" format="reference"/>
</declare-styleable>

View file

@ -225,6 +225,8 @@
<item name="purchase_dialog_active_card_bg">@drawable/dialog_active_card_bg_light</item>
<item name="purchase_dialog_shadow_btn_bg">@drawable/purchase_dialog_shadow_btn_bg_light</item>
<item name="bottom_nav_shadow">@drawable/bg_bottom_bar_shadow_with_line_day</item>
</style>
<style name="OverflowMenuButton" parent="@style/Widget.AppCompat.ActionButton.Overflow">
@ -438,6 +440,8 @@
<item name="purchase_dialog_active_card_bg">@drawable/dialog_active_card_bg_dark</item>
<item name="purchase_dialog_shadow_btn_bg">@drawable/purchase_dialog_shadow_btn_bg_dark</item>
<item name="bottom_nav_shadow">@drawable/bg_bottom_bar_shadow_with_line_night</item>
</style>
<style name="FreeVersionBanner" parent="OsmandDarkTheme">

View file

@ -1,5 +1,6 @@
package net.osmand.plus;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import net.osmand.IndexConstants;
@ -314,7 +315,7 @@ public class GPXDatabase {
return false;
}
public boolean updateSplit(GpxDataItem item, int splitType, double splitInterval) {
public boolean updateSplit(@NonNull GpxDataItem item, int splitType, double splitInterval) {
SQLiteConnection db = openConnection(false);
if (db != null){
try {

View file

@ -26,6 +26,7 @@ import net.osmand.plus.GPXUtilities.WptPt;
import net.osmand.plus.GpxSelectionHelper;
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.LockableViewPager;
import net.osmand.plus.OsmAndAppCustomization;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
@ -53,7 +54,7 @@ public class TrackActivity extends TabActivity {
private File file = null;
private GPXFile gpxFile;
private GpxDataItem gpxDataItem;
ViewPager mViewPager;
private LockableViewPager viewPager;
private long modifiedTime = -1;
private List<GpxDisplayGroup> displayGroups;
private List<GpxDisplayGroup> originalGroups = new ArrayList<>();
@ -240,8 +241,9 @@ public class TrackActivity extends TabActivity {
super.onResume();
stopped = false;
mViewPager = (ViewPager) findViewById(R.id.pager);
setViewPagerAdapter(mViewPager, new ArrayList<TabActivity.TabItem>());
viewPager = (LockableViewPager) findViewById(R.id.pager);
viewPager.setSwipeLocked(true);
setViewPagerAdapter(viewPager, new ArrayList<TabActivity.TabItem>());
new GPXFileLoaderTask(this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void) null);
}
@ -332,13 +334,13 @@ public class TrackActivity extends TabActivity {
((TrackPointFragment) frag).setContent();
}
}
OsmandFragmentPagerAdapter pagerAdapter = (OsmandFragmentPagerAdapter) mViewPager.getAdapter();
OsmandFragmentPagerAdapter pagerAdapter = (OsmandFragmentPagerAdapter) viewPager.getAdapter();
if (pagerAdapter != null) {
pagerAdapter.addTab(getTabIndicator(R.string.gpx_track, TrackSegmentFragment.class));
if (isHavingWayPoints() || isHavingRoutePoints()) {
pagerAdapter.addTab(getTabIndicator(R.string.points, TrackPointFragment.class));
if (openPointsTab) {
mViewPager.setCurrentItem(1, false);
viewPager.setCurrentItem(1, false);
}
}
@ -361,8 +363,8 @@ public class TrackActivity extends TabActivity {
position = 1;
break;
}
if (position != -1 && position != mViewPager.getCurrentItem()) {
mViewPager.setCurrentItem(position);
if (position != -1 && position != viewPager.getCurrentItem()) {
viewPager.setCurrentItem(position);
return true;
}
return false;

View file

@ -14,10 +14,10 @@ import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.AppCompatCheckBox;
import android.support.v7.widget.ListPopupWindow;
import android.support.v7.widget.SwitchCompat;
import android.text.SpannableString;
@ -1180,10 +1180,12 @@ public class GpxUiHelper {
return values;
}
public static OrderedLineDataSet createGPXElevationDataSet(OsmandApplication ctx, LineChart mChart,
GPXTrackAnalysis analysis,
GPXDataSetAxisType axisType,
boolean useRightAxis, boolean drawFilled) {
public static OrderedLineDataSet createGPXElevationDataSet(@NonNull OsmandApplication ctx,
@NonNull LineChart mChart,
@NonNull GPXTrackAnalysis analysis,
@NonNull GPXDataSetAxisType axisType,
boolean useRightAxis,
boolean drawFilled) {
OsmandSettings settings = ctx.getSettings();
OsmandSettings.MetricsConstants mc = settings.METRIC_SYSTEM.get();
boolean useFeet = (mc == OsmandSettings.MetricsConstants.MILES_AND_FEET) || (mc == OsmandSettings.MetricsConstants.MILES_AND_YARDS);
@ -1265,10 +1267,12 @@ public class GpxUiHelper {
return dataSet;
}
public static OrderedLineDataSet createGPXSpeedDataSet(OsmandApplication ctx, LineChart mChart,
GPXTrackAnalysis analysis,
GPXDataSetAxisType axisType,
boolean useRightAxis, boolean drawFilled) {
public static OrderedLineDataSet createGPXSpeedDataSet(@NonNull OsmandApplication ctx,
@NonNull LineChart mChart,
@NonNull GPXTrackAnalysis analysis,
@NonNull GPXDataSetAxisType axisType,
boolean useRightAxis,
boolean drawFilled) {
OsmandSettings settings = ctx.getSettings();
boolean light = settings.isLightContent();
@ -1412,11 +1416,13 @@ public class GpxUiHelper {
return dataSet;
}
public static OrderedLineDataSet createGPXSlopeDataSet(OsmandApplication ctx, LineChart mChart,
GPXTrackAnalysis analysis,
GPXDataSetAxisType axisType,
List<Entry> eleValues,
boolean useRightAxis, boolean drawFilled) {
public static OrderedLineDataSet createGPXSlopeDataSet(@NonNull OsmandApplication ctx,
@NonNull LineChart mChart,
@NonNull GPXTrackAnalysis analysis,
@NonNull GPXDataSetAxisType axisType,
@Nullable List<Entry> eleValues,
boolean useRightAxis,
boolean drawFilled) {
if (axisType == GPXDataSetAxisType.TIME) {
return null;
}

View file

@ -708,7 +708,7 @@ public class SplitSegmentDialogFragment extends DialogFragment {
return (OsmandApplication) getActivity().getApplication();
}
public static boolean showInstance(TrackActivity trackActivity) {
public static boolean showInstance(@NonNull TrackActivity trackActivity) {
try {
SplitSegmentDialogFragment fragment = new SplitSegmentDialogFragment();
fragment.show(trackActivity.getSupportFragmentManager(), TAG);

File diff suppressed because it is too large Load diff

View file

@ -29,6 +29,7 @@ import android.graphics.Typeface;
import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.NonNull;
import android.support.v4.util.Pair;
import android.support.v4.view.ViewCompat;
import android.support.v4.view.ViewPager;
@ -61,7 +62,7 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
}
public interface CustomTabProvider {
public View getCustomTabView(ViewGroup parent, int position);
public View getCustomTabView(@NonNull ViewGroup parent, int position);
public void select(View tab);
public void deselect(View tab);
}