Fix segment appearance

This commit is contained in:
PavelRatushny 2017-07-04 13:23:13 +03:00
parent 88b571efb6
commit e21bbe8678
4 changed files with 133 additions and 99 deletions

View file

@ -198,12 +198,14 @@
</LinearLayout> </LinearLayout>
<View <View
android:id="@+id/elevation_divider"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp" android:layout_height="1dp"
android:layout_marginLeft="28dp" android:layout_marginLeft="28dp"
android:background="?attr/dashboard_divider"/> android:background="?attr/dashboard_divider"/>
<LinearLayout <LinearLayout
android:id="@+id/elevation_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:orientation="horizontal"
@ -379,12 +381,14 @@
</LinearLayout> </LinearLayout>
<View <View
android:id="@+id/speed_divider"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp" android:layout_height="1dp"
android:layout_marginLeft="28dp" android:layout_marginLeft="28dp"
android:background="?attr/dashboard_divider"/> android:background="?attr/dashboard_divider"/>
<LinearLayout <LinearLayout
android:id="@+id/speed_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:orientation="horizontal"

View file

@ -37,6 +37,7 @@ public class TrackActivity extends TabActivity {
public static final String TRACK_FILE_NAME = "TRACK_FILE_NAME"; public static final String TRACK_FILE_NAME = "TRACK_FILE_NAME";
public static final String CURRENT_RECORDING = "CURRENT_RECORDING"; public static final String CURRENT_RECORDING = "CURRENT_RECORDING";
public final String OPEN_SPLIT_SEGMENTS = "OPEN_SPLIT_SEGMENTS";
protected List<WeakReference<Fragment>> fragList = new ArrayList<>(); protected List<WeakReference<Fragment>> fragList = new ArrayList<>();
protected PagerSlidingTabStrip slidingTabLayout; protected PagerSlidingTabStrip slidingTabLayout;
private File file = null; private File file = null;

View file

@ -13,6 +13,7 @@ import android.view.ViewGroup;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
@ -31,6 +32,8 @@ import net.osmand.plus.activities.TrackActivity;
import net.osmand.plus.base.OsmAndListFragment; import net.osmand.plus.base.OsmAndListFragment;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import org.w3c.dom.Text;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
@ -408,26 +411,42 @@ public class SplitSegmentFragment extends OsmAndListFragment {
distanceOrTimeSpanValue.setText(OsmAndFormatter.getFormattedDistance(analysis.totalDistance, app)); distanceOrTimeSpanValue.setText(OsmAndFormatter.getFormattedDistance(analysis.totalDistance, app));
distanceOrTimeSpanText.setText(app.getString(R.string.distance)); distanceOrTimeSpanText.setText(app.getString(R.string.distance));
} else { } else {
if (analysis.timeSpan > 0) {
distanceOrTimeSpanValue.setText(OsmAndFormatter.getFormattedDuration((int) (analysis.timeSpan / 1000), app)); distanceOrTimeSpanValue.setText(OsmAndFormatter.getFormattedDuration((int) (analysis.timeSpan / 1000), app));
} else {
distanceOrTimeSpanValue.setText("-");
}
distanceOrTimeSpanText.setText(app.getString(R.string.shared_string_time_span)); distanceOrTimeSpanText.setText(app.getString(R.string.shared_string_time_span));
} }
TextView startTimeValue = (TextView) convertView.findViewById(R.id.start_time_value);
TextView startDateValue = (TextView) convertView.findViewById(R.id.start_date_value);
TextView endTimeValue = (TextView) convertView.findViewById(R.id.end_time_value);
TextView endDateValue = (TextView) convertView.findViewById(R.id.end_date_value);
if (analysis.timeSpan > 0) { if (analysis.timeSpan > 0) {
DateFormat tf = SimpleDateFormat.getTimeInstance(DateFormat.SHORT); DateFormat tf = SimpleDateFormat.getTimeInstance(DateFormat.SHORT);
DateFormat df = SimpleDateFormat.getDateInstance(DateFormat.MEDIUM); DateFormat df = SimpleDateFormat.getDateInstance(DateFormat.MEDIUM);
Date start = new Date(analysis.startTime); Date start = new Date(analysis.startTime);
((TextView) convertView.findViewById(R.id.start_time_value)) startTimeValue.setText(tf.format(start));
.setText(tf.format(start)); startDateValue.setText(df.format(start));
((TextView) convertView.findViewById(R.id.start_date_value))
.setText(df.format(start));
Date end = new Date(analysis.endTime); Date end = new Date(analysis.endTime);
((TextView) convertView.findViewById(R.id.end_time_value)) endTimeValue.setText(tf.format(end));
.setText(tf.format(end)); endDateValue.setText(df.format(end));
((TextView) convertView.findViewById(R.id.end_date_value)) } else {
.setText(df.format(end)); startTimeValue.setText("-");
startDateValue.setText("-");
endTimeValue.setText("-");
endDateValue.setText("-");
} }
View elevationDivider = convertView.findViewById(R.id.elevation_divider);
View elevationSection = convertView.findViewById(R.id.elevation_layout);
if (analysis.hasElevationData) {
elevationDivider.setVisibility(View.VISIBLE);
elevationSection.setVisibility(View.VISIBLE);
((TextView) convertView.findViewById(R.id.average_altitude_value)) ((TextView) convertView.findViewById(R.id.average_altitude_value))
.setText(OsmAndFormatter.getFormattedAlt(analysis.avgElevation, app)); .setText(OsmAndFormatter.getFormattedAlt(analysis.avgElevation, app));
@ -456,31 +475,37 @@ public class SplitSegmentFragment extends OsmAndListFragment {
.setVisibility(View.GONE); .setVisibility(View.GONE);
} }
TextView ascentValue = (TextView) convertView.findViewById(R.id.ascent_value);
TextView descentValue = (TextView) convertView.findViewById(R.id.descent_value);
TextView ascentDescentValue = (TextView) convertView.findViewById(R.id.ascent_descent_value);
String asc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationUp, app); String asc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationUp, app);
String desc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationDown, app); String desc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationDown, app);
String asc_desc = asc.substring(0, asc.indexOf(" ")).concat("/").concat(desc); String asc_desc = asc.substring(0, asc.indexOf(" ")).concat("/").concat(desc);
if (asc_desc.length() > 9) { if (asc_desc.length() > 9) {
(convertView.findViewById(R.id.ascent_value)) ascentValue.setVisibility(View.VISIBLE);
.setVisibility(View.VISIBLE); descentValue.setVisibility(View.VISIBLE);
(convertView.findViewById(R.id.descent_value)) ascentValue.setText(asc);
.setVisibility(View.VISIBLE); descentValue.setText(desc);
((TextView) convertView.findViewById(R.id.ascent_value)) ascentDescentValue.setVisibility(View.GONE);
.setText(asc);
((TextView) convertView.findViewById(R.id.descent_value))
.setText(desc);
(convertView.findViewById(R.id.ascent_descent_value))
.setVisibility(View.GONE);
} else { } else {
(convertView.findViewById(R.id.ascent_descent_value)) ascentDescentValue.setVisibility(View.VISIBLE);
.setVisibility(View.VISIBLE); ascentDescentValue.setText(asc_desc);
((TextView) convertView.findViewById(R.id.ascent_descent_value)) ascentValue.setVisibility(View.GONE);
.setText(asc_desc); descentValue.setVisibility(View.GONE);
(convertView.findViewById(R.id.ascent_value))
.setVisibility(View.GONE);
(convertView.findViewById(R.id.descent_value))
.setVisibility(View.GONE);
} }
} else {
elevationDivider.setVisibility(View.GONE);
elevationSection.setVisibility(View.GONE);
}
View speedDivider = convertView.findViewById(R.id.speed_divider);
View speedSection = convertView.findViewById(R.id.speed_layout);
if (analysis.hasSpeedData) {
speedDivider.setVisibility(View.VISIBLE);
speedSection.setVisibility(View.VISIBLE);
((TextView) convertView.findViewById(R.id.moving_time_value)) ((TextView) convertView.findViewById(R.id.moving_time_value))
.setText(Algorithms.formatDuration((int) (analysis.timeMoving / 1000), app.accessibilityEnabled())); .setText(Algorithms.formatDuration((int) (analysis.timeMoving / 1000), app.accessibilityEnabled()));
((TextView) convertView.findViewById(R.id.average_speed_value)) ((TextView) convertView.findViewById(R.id.average_speed_value))
@ -525,6 +550,10 @@ public class SplitSegmentFragment extends OsmAndListFragment {
((TextView) convertView.findViewById(R.id.max_min_speed_text)) ((TextView) convertView.findViewById(R.id.max_min_speed_text))
.setText(app.getString(R.string.max_min)); .setText(app.getString(R.string.max_min));
} }
} else {
speedDivider.setVisibility(View.GONE);
speedSection.setVisibility(View.GONE);
}
} }
} }
return convertView; return convertView;

View file

@ -1475,7 +1475,7 @@ public class TrackSegmentFragment extends OsmAndListFragment {
getMyActivity().getSupportFragmentManager() getMyActivity().getSupportFragmentManager()
.beginTransaction() .beginTransaction()
.replace(R.id.track_activity_layout, new SplitSegmentFragment()) .replace(R.id.track_activity_layout, new SplitSegmentFragment())
.addToBackStack("open_split_segments") .addToBackStack(getMyActivity().OPEN_SPLIT_SEGMENTS)
.commit(); .commit();
} }