Fix segment appearance
This commit is contained in:
parent
88b571efb6
commit
e21bbe8678
4 changed files with 133 additions and 99 deletions
|
@ -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"
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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,122 +411,148 @@ 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 {
|
||||||
distanceOrTimeSpanValue.setText(OsmAndFormatter.getFormattedDuration((int) (analysis.timeSpan / 1000), app));
|
if (analysis.timeSpan > 0) {
|
||||||
|
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("-");
|
||||||
}
|
}
|
||||||
|
|
||||||
((TextView) convertView.findViewById(R.id.average_altitude_value))
|
View elevationDivider = convertView.findViewById(R.id.elevation_divider);
|
||||||
.setText(OsmAndFormatter.getFormattedAlt(analysis.avgElevation, app));
|
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))
|
||||||
|
.setText(OsmAndFormatter.getFormattedAlt(analysis.avgElevation, app));
|
||||||
|
|
||||||
|
String min = OsmAndFormatter.getFormattedAlt(analysis.minElevation, app);
|
||||||
|
String max = OsmAndFormatter.getFormattedAlt(analysis.maxElevation, app);
|
||||||
|
String min_max_elevation = min.substring(0, min.indexOf(" ")).concat("/").concat(max);
|
||||||
|
if (min_max_elevation.length() > 9) {
|
||||||
|
(convertView.findViewById(R.id.min_altitude_value))
|
||||||
|
.setVisibility(View.VISIBLE);
|
||||||
|
(convertView.findViewById(R.id.max_altitude_value))
|
||||||
|
.setVisibility(View.VISIBLE);
|
||||||
|
((TextView) convertView.findViewById(R.id.min_altitude_value))
|
||||||
|
.setText(min);
|
||||||
|
((TextView) convertView.findViewById(R.id.max_altitude_value))
|
||||||
|
.setText(max);
|
||||||
|
(convertView.findViewById(R.id.min_max_altitude_value))
|
||||||
|
.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
(convertView.findViewById(R.id.min_max_altitude_value))
|
||||||
|
.setVisibility(View.VISIBLE);
|
||||||
|
((TextView) convertView.findViewById(R.id.min_max_altitude_value))
|
||||||
|
.setText(min_max_elevation);
|
||||||
|
(convertView.findViewById(R.id.min_altitude_value))
|
||||||
|
.setVisibility(View.GONE);
|
||||||
|
(convertView.findViewById(R.id.max_altitude_value))
|
||||||
|
.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 desc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationDown, app);
|
||||||
|
String asc_desc = asc.substring(0, asc.indexOf(" ")).concat("/").concat(desc);
|
||||||
|
if (asc_desc.length() > 9) {
|
||||||
|
ascentValue.setVisibility(View.VISIBLE);
|
||||||
|
descentValue.setVisibility(View.VISIBLE);
|
||||||
|
ascentValue.setText(asc);
|
||||||
|
descentValue.setText(desc);
|
||||||
|
ascentDescentValue.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
ascentDescentValue.setVisibility(View.VISIBLE);
|
||||||
|
ascentDescentValue.setText(asc_desc);
|
||||||
|
ascentValue.setVisibility(View.GONE);
|
||||||
|
descentValue.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
String min = OsmAndFormatter.getFormattedAlt(analysis.minElevation, app);
|
|
||||||
String max = OsmAndFormatter.getFormattedAlt(analysis.maxElevation, app);
|
|
||||||
String min_max_elevation = min.substring(0, min.indexOf(" ")).concat("/").concat(max);
|
|
||||||
if (min_max_elevation.length() > 9) {
|
|
||||||
(convertView.findViewById(R.id.min_altitude_value))
|
|
||||||
.setVisibility(View.VISIBLE);
|
|
||||||
(convertView.findViewById(R.id.max_altitude_value))
|
|
||||||
.setVisibility(View.VISIBLE);
|
|
||||||
((TextView) convertView.findViewById(R.id.min_altitude_value))
|
|
||||||
.setText(min);
|
|
||||||
((TextView) convertView.findViewById(R.id.max_altitude_value))
|
|
||||||
.setText(max);
|
|
||||||
(convertView.findViewById(R.id.min_max_altitude_value))
|
|
||||||
.setVisibility(View.GONE);
|
|
||||||
} else {
|
} else {
|
||||||
(convertView.findViewById(R.id.min_max_altitude_value))
|
elevationDivider.setVisibility(View.GONE);
|
||||||
.setVisibility(View.VISIBLE);
|
elevationSection.setVisibility(View.GONE);
|
||||||
((TextView) convertView.findViewById(R.id.min_max_altitude_value))
|
|
||||||
.setText(min_max_elevation);
|
|
||||||
(convertView.findViewById(R.id.min_altitude_value))
|
|
||||||
.setVisibility(View.GONE);
|
|
||||||
(convertView.findViewById(R.id.max_altitude_value))
|
|
||||||
.setVisibility(View.GONE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String asc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationUp, app);
|
View speedDivider = convertView.findViewById(R.id.speed_divider);
|
||||||
String desc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationDown, app);
|
View speedSection = convertView.findViewById(R.id.speed_layout);
|
||||||
String asc_desc = asc.substring(0, asc.indexOf(" ")).concat("/").concat(desc);
|
if (analysis.hasSpeedData) {
|
||||||
if (asc_desc.length() > 9) {
|
speedDivider.setVisibility(View.VISIBLE);
|
||||||
(convertView.findViewById(R.id.ascent_value))
|
speedSection.setVisibility(View.VISIBLE);
|
||||||
.setVisibility(View.VISIBLE);
|
|
||||||
(convertView.findViewById(R.id.descent_value))
|
|
||||||
.setVisibility(View.VISIBLE);
|
|
||||||
((TextView) convertView.findViewById(R.id.ascent_value))
|
|
||||||
.setText(asc);
|
|
||||||
((TextView) convertView.findViewById(R.id.descent_value))
|
|
||||||
.setText(desc);
|
|
||||||
(convertView.findViewById(R.id.ascent_descent_value))
|
|
||||||
.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
(convertView.findViewById(R.id.ascent_descent_value))
|
|
||||||
.setVisibility(View.VISIBLE);
|
|
||||||
((TextView) convertView.findViewById(R.id.ascent_descent_value))
|
|
||||||
.setText(asc_desc);
|
|
||||||
(convertView.findViewById(R.id.ascent_value))
|
|
||||||
.setVisibility(View.GONE);
|
|
||||||
(convertView.findViewById(R.id.descent_value))
|
|
||||||
.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
((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))
|
||||||
.setText(OsmAndFormatter.getFormattedSpeed(analysis.avgSpeed, app));
|
.setText(OsmAndFormatter.getFormattedSpeed(analysis.avgSpeed, app));
|
||||||
|
|
||||||
String maxSpeed = OsmAndFormatter.getFormattedSpeed(analysis.maxSpeed, app);
|
String maxSpeed = OsmAndFormatter.getFormattedSpeed(analysis.maxSpeed, app);
|
||||||
String minSpeed = OsmAndFormatter.getFormattedSpeed(analysis.minSpeed, app);
|
String minSpeed = OsmAndFormatter.getFormattedSpeed(analysis.minSpeed, app);
|
||||||
String max_min_speed = maxSpeed.substring(0, maxSpeed.indexOf(" ")).concat("/").concat(minSpeed.substring(0, minSpeed.indexOf(" ")));
|
String max_min_speed = maxSpeed.substring(0, maxSpeed.indexOf(" ")).concat("/").concat(minSpeed.substring(0, minSpeed.indexOf(" ")));
|
||||||
if (minSpeed.substring(0, minSpeed.indexOf(" ")).equals("0") || minSpeed.substring(0, minSpeed.indexOf(" ")).equals("0.0")) {
|
if (minSpeed.substring(0, minSpeed.indexOf(" ")).equals("0") || minSpeed.substring(0, minSpeed.indexOf(" ")).equals("0.0")) {
|
||||||
(convertView.findViewById(R.id.max_speed_value))
|
(convertView.findViewById(R.id.max_speed_value))
|
||||||
.setVisibility(View.VISIBLE);
|
.setVisibility(View.VISIBLE);
|
||||||
(convertView.findViewById(R.id.min_speed_value))
|
(convertView.findViewById(R.id.min_speed_value))
|
||||||
.setVisibility(View.GONE);
|
.setVisibility(View.GONE);
|
||||||
((TextView) convertView.findViewById(R.id.max_speed_value))
|
((TextView) convertView.findViewById(R.id.max_speed_value))
|
||||||
.setText(maxSpeed);
|
.setText(maxSpeed);
|
||||||
(convertView.findViewById(R.id.max_min_speed_value))
|
(convertView.findViewById(R.id.max_min_speed_value))
|
||||||
.setVisibility(View.GONE);
|
.setVisibility(View.GONE);
|
||||||
((TextView) convertView.findViewById(R.id.max_min_speed_text))
|
((TextView) convertView.findViewById(R.id.max_min_speed_text))
|
||||||
.setText(app.getString(R.string.shared_string_max));
|
.setText(app.getString(R.string.shared_string_max));
|
||||||
} else if (max_min_speed.length() > 9) {
|
} else if (max_min_speed.length() > 9) {
|
||||||
(convertView.findViewById(R.id.max_speed_value))
|
(convertView.findViewById(R.id.max_speed_value))
|
||||||
.setVisibility(View.VISIBLE);
|
.setVisibility(View.VISIBLE);
|
||||||
(convertView.findViewById(R.id.min_speed_value))
|
(convertView.findViewById(R.id.min_speed_value))
|
||||||
.setVisibility(View.VISIBLE);
|
.setVisibility(View.VISIBLE);
|
||||||
((TextView) convertView.findViewById(R.id.max_speed_value))
|
((TextView) convertView.findViewById(R.id.max_speed_value))
|
||||||
.setText(maxSpeed);
|
.setText(maxSpeed);
|
||||||
((TextView) convertView.findViewById(R.id.min_speed_value))
|
((TextView) convertView.findViewById(R.id.min_speed_value))
|
||||||
.setText(minSpeed);
|
.setText(minSpeed);
|
||||||
(convertView.findViewById(R.id.max_min_speed_value))
|
(convertView.findViewById(R.id.max_min_speed_value))
|
||||||
.setVisibility(View.GONE);
|
.setVisibility(View.GONE);
|
||||||
((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 {
|
||||||
|
(convertView.findViewById(R.id.max_min_speed_value))
|
||||||
|
.setVisibility(View.VISIBLE);
|
||||||
|
((TextView) convertView.findViewById(R.id.max_min_speed_value))
|
||||||
|
.setText(max_min_speed);
|
||||||
|
(convertView.findViewById(R.id.max_speed_value))
|
||||||
|
.setVisibility(View.GONE);
|
||||||
|
(convertView.findViewById(R.id.min_speed_value))
|
||||||
|
.setVisibility(View.GONE);
|
||||||
|
((TextView) convertView.findViewById(R.id.max_min_speed_text))
|
||||||
|
.setText(app.getString(R.string.max_min));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
(convertView.findViewById(R.id.max_min_speed_value))
|
speedDivider.setVisibility(View.GONE);
|
||||||
.setVisibility(View.VISIBLE);
|
speedSection.setVisibility(View.GONE);
|
||||||
((TextView) convertView.findViewById(R.id.max_min_speed_value))
|
|
||||||
.setText(max_min_speed);
|
|
||||||
(convertView.findViewById(R.id.max_speed_value))
|
|
||||||
.setVisibility(View.GONE);
|
|
||||||
(convertView.findViewById(R.id.min_speed_value))
|
|
||||||
.setVisibility(View.GONE);
|
|
||||||
((TextView) convertView.findViewById(R.id.max_min_speed_text))
|
|
||||||
.setText(app.getString(R.string.max_min));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue