Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2017-02-18 14:00:20 +01:00
commit 6cee67c626
12 changed files with 541 additions and 159 deletions

View file

@ -4,19 +4,6 @@
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/current_track"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_card"
android:orientation="vertical">
<include
layout="@layout/dash_gpx_track_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
<ExpandableListView
android:id="@android:id/list"
android:layout_width="fill_parent"
@ -25,7 +12,9 @@
android:layout_marginRight="0dp"
android:layout_marginTop="0dp"
android:layout_weight="1"
android:divider="@null"
android:dividerHeight="0dp"
android:drawSelectorOnTop="false"
android:groupIndicator="@android:color/transparent"/>
</LinearLayout>

View file

@ -0,0 +1,207 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
android:minHeight="@dimen/list_item_height"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:src="@drawable/bg_shadow_list_bottom"/>
<View
android:layout_width="match_parent"
android:layout_height="16dp"/>
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<CheckBox
android:id="@+id/check_local_index"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/local_index_check_right_margin"
android:layout_marginTop="12dp"
android:focusable="false"
android:visibility="gone"/>
<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/list_content_padding"
android:layout_marginTop="12dp"
android:src="@drawable/monitoring_rec_big"
android:visibility="visible"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="12dp"
android:layout_marginLeft="@dimen/subHeaderMarginLeft"
android:layout_marginRight="@dimen/showAllButtonMarginRight"
android:gravity="center_vertical"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_list_text_size"
android:text="@string/current_track"/>
<TextView
android:id="@+id/segment_time_div"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
android:text=" • "/>
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/segment_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:text="0:05:34"/>
</LinearLayout>
<LinearLayout
android:id="@+id/read_section"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="visible">
<ImageView
android:id="@+id/distance_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="@dimen/gpx_small_icon_margin"
android:src="@drawable/ic_small_distance"/>
<TextView
android:id="@+id/distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/gpx_small_text_margin"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size"/>
<ImageView
android:id="@+id/points_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="@dimen/gpx_small_icon_margin"
android:src="@drawable/ic_small_point"/>
<TextView
android:id="@+id/points_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/gpx_small_text_margin"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size"/>
</LinearLayout>
<LinearLayout
android:id="@+id/unknown_section"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="gone">
<TextView
android:id="@+id/date_and_size_details"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size"/>
</LinearLayout>
<TextView
android:id="@+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_sub_text_size"
android:visibility="gone"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/action_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textColor="?attr/color_dialog_buttons"
android:background="?attr/selectableItemBackground"
android:drawableLeft="@drawable/ic_action_rec_stop"
android:text="@string/shared_string_control_stop"/>
<Button
android:id="@+id/save_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:drawableLeft="@drawable/ic_action_gsave_dark"
android:textColor="?attr/color_dialog_buttons"
android:text="@string/shared_string_save"
android:visibility="gone"
tools:visibility="visible"/>
</LinearLayout>
</LinearLayout>
</FrameLayout>
<include layout="@layout/list_item_divider"/>
</LinearLayout>

View file

@ -9,7 +9,15 @@
android:gravity="center_vertical">
<View
android:id="@+id/divider"
android:id="@+id/divider_list"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginLeft="54dp"
android:background="?attr/dashboard_divider"
android:visibility="gone"/>
<View
android:id="@+id/divider_dash"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider"/>
@ -24,7 +32,7 @@
android:id="@+id/check_local_index"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/local_index_check_right_margin"
android:layout_marginLeft="@dimen/list_content_padding"
android:focusable="false"
android:visibility="gone"/>
@ -148,7 +156,7 @@
android:src="@drawable/ic_action_gsave_dark"
android:visibility="gone"
tools:visibility="visible"/>
<ImageButton
android:id="@+id/stop"
android:layout_width="@dimen/list_item_height"

View file

@ -4,59 +4,74 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
android:minHeight="@dimen/list_item_height"
android:orientation="horizontal"
android:background="?attr/expandable_list_item_background"
android:paddingLeft="@dimen/list_content_padding">
android:orientation="vertical">
<CheckBox
android:id="@+id/toggle_item"
android:layout_width="wrap_content"
<LinearLayout
android:id="@+id/group_divider"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include layout="@layout/list_item_divider"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="?attr/dashboard_button"
android:focusable="false"
android:visibility="gone"
tools:visiblity="visible"/>
android:paddingLeft="@dimen/list_content_padding"
android:minHeight="@dimen/list_item_height"
android:background="?attr/expandable_list_item_background">
<ImageView
android:id="@+id/category_icon"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_vertical"/>
<CheckBox
android:id="@+id/toggle_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="?attr/dashboard_button"
android:focusable="false"
android:visibility="gone"
tools:visiblity="visible"/>
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/category_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/list_content_padding"
android:layout_weight="1"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:text="Category name"/>
<ImageView
android:id="@+id/category_icon"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_vertical"/>
<ImageView
android:id="@+id/options"
android:contentDescription="@string/shared_string_more"
android:layout_width="46dp"
android:layout_height="match_parent"
android:layout_marginRight="4dp"
android:layout_gravity="center_vertical"
android:background="?attr/dashboard_button"
android:focusable="false"
android:scaleType="center"
android:src="@drawable/ic_overflow_menu_white"
android:visibility="gone"
tools:visiblity="visible"/>
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/category_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/list_content_padding"
android:layout_weight="1"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:text="Category name"/>
<ImageView
android:id="@+id/explist_indicator"
android:layout_width="24dp"
android:layout_height="match_parent"
android:scaleType="center"
android:layout_gravity="center_vertical"
android:layout_marginRight="@dimen/list_content_padding"/>
<ImageView
android:id="@+id/options"
android:contentDescription="@string/shared_string_more"
android:layout_width="46dp"
android:layout_height="match_parent"
android:layout_marginRight="4dp"
android:layout_gravity="center_vertical"
android:background="?attr/dashboard_button"
android:focusable="false"
android:scaleType="center"
android:src="@drawable/ic_overflow_menu_white"
android:visibility="gone"
tools:visiblity="visible"/>
</LinearLayout>
<ImageView
android:id="@+id/explist_indicator"
android:layout_width="24dp"
android:layout_height="match_parent"
android:scaleType="center"
android:layout_gravity="center_vertical"
android:layout_marginRight="@dimen/list_content_padding"/>
</LinearLayout>
</LinearLayout>

View file

@ -15,6 +15,14 @@
android:background="?attr/dashboard_divider"
android:visibility="gone"/>
<View
android:id="@+id/list_divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider"
android:layout_marginLeft="54dp"
android:visibility="gone"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -27,7 +35,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="@dimen/favorites_icon_right_margin"
android:layout_marginRight="@dimen/list_content_padding"
android:focusable="false"
android:visibility="gone"
tools:visibility="visible"/>

View file

@ -13,6 +13,9 @@
android:layout_marginRight="0dp"
android:layout_marginTop="0dp"
android:layout_weight="1"
android:divider="@null"
android:dividerHeight="0dp"
android:drawSelectorOnTop="false"
android:groupIndicator="@android:color/transparent" />
</LinearLayout>

View file

@ -65,8 +65,8 @@
<color name="list_sub_menu_background_dark">#475259</color>
<!-- <color name="list_item_light">@color/color_white</color>
<color name="list_item_background_dark">#333b40</color> -->
<color name="list_item_light">#00000000</color>
<color name="list_item_dark">#00000000</color>
<color name="list_item_light">#fff</color>
<color name="list_item_dark">#333b40</color>
<color name="list_item_light_pressed">#8cd0d0d0</color>
<color name="list_item_dark_pressed">#be39464d</color>
<color name="bg_color_light">#fff</color>

View file

@ -9,6 +9,7 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
-->
<string name="shared_string_tracks">Tracks</string>
<string name="routing_attr_driving_style_name">Driving style</string>
<string name="routing_attr_driving_style_description">Safe, fast or balanced driving</string>
<string name="route_altitude">Route altitude</string>

View file

@ -45,6 +45,13 @@ public class OsmAndFormatter {
}
}
public static String getFormattedDurationShort(int seconds, OsmandApplication ctx) {
int hours = seconds / (60 * 60);
int minutes = (seconds / 60) % 60;
int sec = seconds % 60;
return hours + ":" + (minutes < 10 ? "0" + minutes : minutes) + ":" + (sec < 10 ? "0" + sec : sec);
}
public static double calculateRoundedDist(double distInMeters, OsmandApplication ctx) {
OsmandSettings settings = ctx.getSettings();
MetricsConstants mc = settings.METRIC_SYSTEM.get();

View file

@ -138,6 +138,10 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.favorites_tree, container, false);
ExpandableListView listView = (ExpandableListView) view.findViewById(android.R.id.list);
View headerView = inflater.inflate(R.layout.list_shadow_header, null, false);
listView.addHeaderView(headerView);
View footerView = inflater.inflate(R.layout.list_shadow_footer, null, false);
listView.addFooterView(footerView);
favouritesAdapter.synchronizeGroups();
listView.setAdapter(favouritesAdapter);
setListView(listView);
@ -159,6 +163,14 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
return view;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
listView.setBackgroundColor(getResources().getColor(
getMyApplication().getSettings().isLightContent() ? R.color.ctx_menu_info_view_bg_light
: R.color.ctx_menu_info_view_bg_dark));
}
@Override
public void onResume() {
super.onResume();
@ -712,10 +724,11 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
}
OsmandApplication app = getMyApplication();
boolean light = app.getSettings().isLightContent();
setCategoryIcon(app, 0, groupPosition, isExpanded, row, light);
final FavoriteGroup model = getGroup(groupPosition);
row.findViewById(R.id.group_divider).setVisibility(groupPosition == 0 ? View.GONE : View.VISIBLE);
setCategoryIcon(app, FavoriteImageDrawable.getOrCreate(getActivity(), model.color, false), groupPosition, isExpanded, row, light);
adjustIndicator(app, groupPosition, isExpanded, row, light);
TextView label = (TextView) row.findViewById(R.id.category_name);
final FavoriteGroup model = getGroup(groupPosition);
label.setText(model.name.length() == 0 ? getString(R.string.shared_string_favorites) : model.name);
if (selectionMode) {
@ -726,22 +739,27 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
ch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
List<FavouritePoint> fvs = model.points;
if (ch.isChecked()) {
groupsToDelete.add(model);
List<FavouritePoint> fvs = model.points;
if (fvs != null) {
favoritesSelected.addAll(fvs);
}
favouritesAdapter.notifyDataSetInvalidated();
} else {
groupsToDelete.remove(model);
if (fvs != null) {
favoritesSelected.removeAll(fvs);
}
}
favouritesAdapter.notifyDataSetInvalidated();
updateSelectionMode(actionMode);
}
});
row.findViewById(R.id.category_icon).setVisibility(View.GONE);
} else {
final CheckBox ch = (CheckBox) row.findViewById(R.id.toggle_item);
ch.setVisibility(View.GONE);
row.findViewById(R.id.category_icon).setVisibility(View.VISIBLE);
}
final View ch = row.findViewById(R.id.options);
if (!selectionMode) {
@ -769,6 +787,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
if (row == null) {
LayoutInflater inflater = getActivity().getLayoutInflater();
row = inflater.inflate(R.layout.favorites_list_item, parent, false);
row.findViewById(R.id.list_divider).setVisibility(View.VISIBLE);
}
TextView name = (TextView) row.findViewById(R.id.favourite_label);

View file

@ -8,6 +8,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
@ -18,11 +19,13 @@ import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.GpxSelectionHelper;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.OsmAndAppCustomization;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.SavingTrackHelper;
import net.osmand.plus.dashboard.DashBaseFragment;
import net.osmand.plus.dashboard.DashboardOnMap;
import net.osmand.plus.dashboard.tools.DashFragmentData;
@ -142,16 +145,16 @@ public class DashTrackFragment extends DashBaseFragment {
if (OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) != null) {
View view = inflater.inflate(R.layout.dash_gpx_track_item, null, false);
AvailableGPXFragment.createCurrentTrackView(view, app);
createCurrentTrackView(view, app);
((TextView) view.findViewById(R.id.name)).setText(R.string.shared_string_currently_recording_track);
AvailableGPXFragment.updateCurrentTrack(view, getActivity(), app);
updateCurrentTrack(view, getActivity(), app);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AvailableGPXFragment.openTrack(getActivity(), null);
}
});
view.findViewById(R.id.divider).setVisibility(View.VISIBLE);
view.findViewById(R.id.divider_dash).setVisibility(View.VISIBLE);
tracks.addView(view);
startHandler(view);
}
@ -178,6 +181,69 @@ public class DashTrackFragment extends DashBaseFragment {
}
}
public static void createCurrentTrackView(View v, final OsmandApplication app) {
((TextView) v.findViewById(R.id.name)).setText(R.string.shared_string_currently_recording_track);
v.findViewById(R.id.time_icon).setVisibility(View.GONE);
v.findViewById(R.id.divider_dash).setVisibility(View.GONE);
v.findViewById(R.id.divider_list).setVisibility(View.GONE);
v.findViewById(R.id.options).setVisibility(View.GONE);
v.findViewById(R.id.stop).setVisibility(View.VISIBLE);
v.findViewById(R.id.check_item).setVisibility(View.GONE);
}
public static void updateCurrentTrack(View v, final Activity ctx, final OsmandApplication app) {
final OsmandMonitoringPlugin plugin = OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class);
if (v == null || ctx == null || app == null || plugin == null) {
return;
}
final boolean isRecording = app.getSettings().SAVE_GLOBAL_TRACK_TO_GPX.get();
ImageButton stop = ((ImageButton) v.findViewById(R.id.stop));
if (isRecording) {
stop.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_rec_stop));
stop.setContentDescription(app.getString(R.string.gpx_monitoring_stop));
} else {
stop.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_rec_start));
stop.setContentDescription(app.getString(R.string.gpx_monitoring_start));
}
stop.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (isRecording) {
plugin.stopRecording();
} else
if (app.getLocationProvider().checkGPSEnabled(ctx)) {
plugin.startGPXMonitoring(ctx);
}
}
});
SavingTrackHelper sth = app.getSavingTrackHelper();
ImageButton save = ((ImageButton) v.findViewById(R.id.show_on_map));
save.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
plugin.saveCurrentTrack();
}
});
if (sth.getPoints() > 0 || sth.getDistance() > 0) {
save.setVisibility(View.VISIBLE);
} else {
save.setVisibility(View.GONE);
}
save.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_gsave_dark));
save.setContentDescription(app.getString(R.string.save_current_track));
((TextView) v.findViewById(R.id.points_count)).setText(String.valueOf(sth.getPoints()));
((TextView) v.findViewById(R.id.distance))
.setText(OsmAndFormatter.getFormattedDistance(sth.getDistance(), app));
v.findViewById(R.id.points_icon).setVisibility(View.VISIBLE);
ImageView distance = (ImageView) v.findViewById(R.id.distance_icon);
distance.setVisibility(View.VISIBLE);
distance.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_small_distance));
ImageView pointsCount = (ImageView) v.findViewById(R.id.points_icon);
pointsCount.setVisibility(View.VISIBLE);
pointsCount.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_small_point));
}
private void updateShowOnMap(final OsmandApplication app, final File f, final View pView, final ImageButton showOnMap) {
final GpxSelectionHelper selectedGpxHelper = app.getSelectedGpxHelper();
final SelectedGpxFile selected = selectedGpxHelper.getSelectedFileByPath(f.getAbsolutePath());
@ -233,7 +299,7 @@ public class DashTrackFragment extends DashBaseFragment {
@Override
public void run() {
if (updateEnable) {
AvailableGPXFragment.updateCurrentTrack(v, getActivity(), getMyApplication());
updateCurrentTrack(v, getActivity(), getMyApplication());
startHandler(v);
}
}

View file

@ -23,6 +23,7 @@ import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ExpandableListView;
@ -94,6 +95,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
private boolean updateEnable;
private GpxInfo currentRecording;
private boolean showOnMapMode;
private View currentGpxView;
@Override
public void onAttach(Context activity) {
@ -115,7 +117,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
@Override
public void run() {
if (getView() != null && updateEnable) {
updateCurrentTrack(getView(), getActivity(), app);
updateCurrentTrack();
if (selectedGpxHelper.getSelectedCurrentRecordingTrack() != null) {
allGpxAdapter.notifyDataSetChanged();
}
@ -155,12 +157,73 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
}
public void updateCurrentTrack() {
if (OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) == null) {
final OsmandMonitoringPlugin plugin = OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class);
if (currentGpxView == null || plugin == null) {
return;
}
updateCurrentTrack(getView(), getActivity(), app);
final boolean isRecording = app.getSettings().SAVE_GLOBAL_TRACK_TO_GPX.get();
ImageView icon = (ImageView) currentGpxView.findViewById(R.id.icon);
icon.setImageDrawable(app.getIconsCache().getIcon(R.drawable.monitoring_rec_big));
final boolean light = app.getSettings().isLightContent();
SavingTrackHelper sth = app.getSavingTrackHelper();
Button stop = (Button) currentGpxView.findViewById(R.id.action_button);
if (isRecording) {
currentGpxView.findViewById(R.id.segment_time_div).setVisibility(View.VISIBLE);
TextView segmentTime = (TextView) currentGpxView.findViewById(R.id.segment_time);
segmentTime.setText(OsmAndFormatter.getFormattedDurationShort((int)(sth.getDuration() / 1000), app));
segmentTime.setVisibility(View.VISIBLE);
stop.setCompoundDrawablesWithIntrinsicBounds(app.getIconsCache()
.getIcon(R.drawable.ic_action_rec_stop, light ? R.color.color_dialog_buttons_light : R.color.color_dialog_buttons_dark), null, null, null);
stop.setText(app.getString(R.string.shared_string_control_stop));
stop.setContentDescription(app.getString(R.string.gpx_monitoring_stop));
} else {
currentGpxView.findViewById(R.id.segment_time_div).setVisibility(View.GONE);
currentGpxView.findViewById(R.id.segment_time).setVisibility(View.GONE);
stop.setCompoundDrawablesWithIntrinsicBounds(app.getIconsCache()
.getIcon(R.drawable.ic_action_rec_start, light ? R.color.color_dialog_buttons_light : R.color.color_dialog_buttons_dark), null, null, null);
stop.setText(app.getString(R.string.shared_string_record));
stop.setContentDescription(app.getString(R.string.gpx_monitoring_start));
}
stop.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (isRecording) {
plugin.stopRecording();
updateCurrentTrack();
} else
if (app.getLocationProvider().checkGPSEnabled(app)) {
plugin.startGPXMonitoring(getActivity());
updateCurrentTrack();
}
}
});
Button save = (Button) currentGpxView.findViewById(R.id.save_button);
save.setCompoundDrawablesWithIntrinsicBounds(app.getIconsCache()
.getIcon(R.drawable.ic_action_gsave_dark, light ? R.color.color_dialog_buttons_light : R.color.color_dialog_buttons_dark), null, null, null);
save.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
plugin.saveCurrentTrack();
updateCurrentTrack();
}
});
if (sth.getPoints() > 0 || sth.getDistance() > 0) {
save.setVisibility(View.VISIBLE);
} else {
save.setVisibility(View.GONE);
}
save.setContentDescription(app.getString(R.string.save_current_track));
((TextView) currentGpxView.findViewById(R.id.points_count)).setText(String.valueOf(sth.getPoints()));
((TextView) currentGpxView.findViewById(R.id.distance))
.setText(OsmAndFormatter.getFormattedDistance(sth.getDistance(), app));
@SuppressWarnings("ConstantConditions")
final CheckBox checkbox = (CheckBox) getView().findViewById(R.id.check_local_index);
final CheckBox checkbox = (CheckBox) currentGpxView.findViewById(R.id.check_local_index);
checkbox.setVisibility(selectionMode && showOnMapMode ? View.VISIBLE : View.GONE);
if (selectionMode && showOnMapMode) {
checkbox.setChecked(selectedItems.contains(currentRecording));
@ -180,85 +243,49 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
}
public static void updateCurrentTrack(View v, final Activity ctx, final OsmandApplication app) {
final OsmandMonitoringPlugin plugin = OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class);
if (v == null || ctx == null || app == null || plugin == null) {
return;
}
final boolean isRecording = app.getSettings().SAVE_GLOBAL_TRACK_TO_GPX.get();
ImageButton stop = ((ImageButton) v.findViewById(R.id.stop));
if (isRecording) {
stop.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_rec_stop));
stop.setContentDescription(app.getString(R.string.gpx_monitoring_stop));
} else {
stop.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_rec_start));
stop.setContentDescription(app.getString(R.string.gpx_monitoring_start));
}
stop.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (isRecording) {
plugin.stopRecording();
} else
if (app.getLocationProvider().checkGPSEnabled(ctx)) {
plugin.startGPXMonitoring(ctx);
}
}
});
SavingTrackHelper sth = app.getSavingTrackHelper();
ImageButton save = ((ImageButton) v.findViewById(R.id.show_on_map));
save.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
plugin.saveCurrentTrack();
}
});
if (sth.getPoints() > 0 || sth.getDistance() > 0) {
save.setVisibility(View.VISIBLE);
} else {
save.setVisibility(View.GONE);
}
save.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_gsave_dark));
save.setContentDescription(app.getString(R.string.save_current_track));
((TextView) v.findViewById(R.id.points_count)).setText(String.valueOf(sth.getPoints()));
((TextView) v.findViewById(R.id.distance))
.setText(OsmAndFormatter.getFormattedDistance(sth.getDistance(), app));
v.findViewById(R.id.points_icon).setVisibility(View.VISIBLE);
ImageView distance = (ImageView) v.findViewById(R.id.distance_icon);
distance.setVisibility(View.VISIBLE);
distance.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_small_distance));
ImageView pointsCount = (ImageView) v.findViewById(R.id.points_icon);
pointsCount.setVisibility(View.VISIBLE);
pointsCount.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_small_point));
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.available_gpx, container, false);
listView = (ExpandableListView) v.findViewById(android.R.id.list);
if (this.adapter != null) {
listView.setAdapter(this.adapter);
}
setHasOptionsMenu(true);
View currentTrackView = v.findViewById(R.id.current_track);
createCurrentTrackView(v, getMyApplication());
if (OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) == null) {
currentTrackView.setVisibility(View.GONE);
} else {
currentTrackView.setVisibility(View.VISIBLE);
if (OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) != null) {
currentGpxView = inflater.inflate(R.layout.current_gpx_item, null, false);
createCurrentTrackView();
listView.addHeaderView(currentGpxView);
/*
currentTrackView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openTrack(getActivity(), null);
}
});
*/
}
View footerView = inflater.inflate(R.layout.list_shadow_footer, null, false);
listView.addFooterView(footerView);
if (this.adapter != null) {
listView.setAdapter(this.adapter);
}
return v;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
listView.setBackgroundColor(getResources().getColor(
app.getSettings().isLightContent() ? R.color.ctx_menu_info_view_bg_light
: R.color.ctx_menu_info_view_bg_dark));
}
public void createCurrentTrackView() {
ImageView distanceI = (ImageView) currentGpxView.findViewById(R.id.distance_icon);
distanceI.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_small_distance));
ImageView pointsI = (ImageView) currentGpxView.findViewById(R.id.points_icon);
pointsI.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_small_point));
updateCurrentTrack();
}
public static void openTrack(Activity a, final File f) {
Intent newIntent = new Intent(a, ((OsmandApplication) a.getApplication()).getAppCustomization().getTrackActivity());
// causes wrong position caching: newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
@ -271,15 +298,6 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
a.startActivity(newIntent);
}
public static void createCurrentTrackView(View v, final OsmandApplication app) {
((TextView) v.findViewById(R.id.name)).setText(R.string.shared_string_currently_recording_track);
v.findViewById(R.id.time_icon).setVisibility(View.GONE);
v.findViewById(R.id.divider).setVisibility(View.GONE);
v.findViewById(R.id.options).setVisibility(View.GONE);
v.findViewById(R.id.stop).setVisibility(View.VISIBLE);
v.findViewById(R.id.check_item).setVisibility(View.GONE);
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
menu.clear();
@ -840,16 +858,55 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
}
@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
public View getGroupView(final int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
View v = convertView;
String group = getGroup(groupPosition);
if (v == null) {
LayoutInflater inflater = getActivity().getLayoutInflater();
v = inflater.inflate(net.osmand.plus.R.layout.expandable_list_item_category, parent, false);
}
StringBuilder t = new StringBuilder(group);
v.findViewById(R.id.group_divider).setVisibility(groupPosition == 0 ? View.GONE : View.VISIBLE);
StringBuilder t = new StringBuilder();
String groupName = group.replaceAll("_", " ").replace(".gpx", "");
if (groupName.length() == 0) {
groupName = getString(R.string.shared_string_tracks);
}
t.append(Character.toUpperCase(groupName.charAt(0)));
if (groupName.length() > 1) {
t.append(groupName.substring(1));
}
boolean light = app.getSettings().isLightContent();
setCategoryIcon(app, 0, groupPosition, isExpanded, v, light);
if (selectionMode) {
final CheckBox ch = (CheckBox) v.findViewById(R.id.toggle_item);
ch.setVisibility(View.VISIBLE);
//ch.setChecked(selectedItems.contains(model));
ch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (ch.isChecked()) {
selectedItems.addAll(data.get(category.get(getGroupPosition(groupPosition))));
} else {
selectedItems.removeAll(data.get(category.get(getGroupPosition(groupPosition))));
}
allGpxAdapter.notifyDataSetInvalidated();
updateSelectionMode(actionMode);
}
});
v.findViewById(R.id.category_icon).setVisibility(View.GONE);
} else {
final CheckBox ch = (CheckBox) v.findViewById(R.id.toggle_item);
ch.setVisibility(View.GONE);
if (isSelectedGroup(groupPosition)) {
setCategoryIcon(app, app.getIconsCache().getIcon(R.drawable.ic_map, R.color.osmand_orange), groupPosition, isExpanded, v, light);
} else {
setCategoryIcon(app, 0, groupPosition, isExpanded, v, light);
}
v.findViewById(R.id.category_icon).setVisibility(View.VISIBLE);
}
adjustIndicator(app, groupPosition, isExpanded, v, light);
TextView nameView = ((TextView) v.findViewById(R.id.category_name));
List<GpxInfo> list = isSelectedGroup(groupPosition) ? selected : data.get(group);
@ -895,7 +952,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
@Override
public String getGroup(int groupPosition) {
if (isSelectedGroup(groupPosition)) {
return app.getString(R.string.shared_string_selected);
return app.getString(R.string.osm_live_active);
}
return category.get(getGroupPosition(groupPosition));
}
@ -1279,9 +1336,11 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
public static void udpateGpxInfoView(View v, GpxInfo child, OsmandApplication app, boolean isDashItem) {
TextView viewName = ((TextView) v.findViewById(R.id.name));
if (!isDashItem) {
v.findViewById(R.id.divider).setVisibility(View.GONE);
v.findViewById(R.id.divider_list).setVisibility(View.VISIBLE);
v.findViewById(R.id.divider_dash).setVisibility(View.GONE);
} else {
v.findViewById(R.id.divider).setVisibility(View.VISIBLE);
v.findViewById(R.id.divider_dash).setVisibility(View.VISIBLE);
v.findViewById(R.id.divider_list).setVisibility(View.GONE);
}
viewName.setText(child.getName());