Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2015-02-25 12:29:52 +01:00
commit 7a664cb920
27 changed files with 644 additions and 353 deletions

View file

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
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/card_bg"
android:orientation="vertical">
<include
layout="@layout/dash_gpx_track_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider"/>
<Button
android:id="@+id/map_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/expandable_list_item_background"
android:text="@string/back_to_map"/>
</LinearLayout>
<ExpandableListView
android:id="@android:id/list"
style="@style/OsmandListView"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:layout_marginTop="0dp"
android:layout_weight="1"
android:background="?attr/expandable_list_background"
android:groupIndicator="@android:color/transparent"/>
</LinearLayout>

View file

@ -1,69 +0,0 @@
<?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="@dimen/dashListItemHeight"
android:orientation="vertical">
<View
android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:id="@+id/icon"
android:layout_width="@dimen/dashNoteIconSize"
android:layout_height="@dimen/dashNoteIconSize"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/dashFavIconMargin"
android:layout_marginRight="@dimen/dashFavIconMargin"
tools:src="@drawable/ic_type_audio" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:lines="1"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/dashFavNameTextSize"
tools:text="@string/lorem_ipsum" />
<TextView
android:id="@+id/descr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:lines="1"
android:textSize="@dimen/showAllButtonTextSize"
android:textColor="?android:textColorSecondary"
tools:text="@string/lorem_ipsum" />
</LinearLayout>
<ImageButton
android:id="@+id/play"
android:layout_width="@dimen/dashListItemHeight"
android:layout_height="@dimen/dashListItemHeight"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/dashFavIconMargin"
android:background="?attr/dashboard_button"
android:src="@drawable/ic_play_light"/>
</LinearLayout>
</LinearLayout>

View file

@ -77,7 +77,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginLeft="4dp" android:layout_marginLeft="4dp"
android:textColor="@color/dashboard_descr_colol" android:textColor="@color/icon_color_light"
android:textSize="@dimen/showAllButtonTextSize"/> android:textSize="@dimen/showAllButtonTextSize"/>
</LinearLayout> </LinearLayout>

View file

@ -1,71 +1,103 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/dashListItemHeight"> android:layout_height="wrap_content"
<View android:layout_width="match_parent" android:minHeight="@dimen/dashListItemHeight"
android:background="?attr/dashboard_divider" android:orientation="vertical">
android:layout_height="1dp"/>
<LinearLayout android:orientation="horizontal" <View
android:id="@+id/divider"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="1dp"
<LinearLayout android:orientation="vertical" android:background="?attr/dashboard_divider"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight="1" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/subHeaderMarginLeft" android:layout_marginLeft="@dimen/subHeaderMarginLeft"
android:layout_marginRight="@dimen/showAllButtonMarginRight" android:layout_marginRight="@dimen/showAllButtonMarginRight"
android:layout_height="wrap_content"> android:layout_weight="1"
<TextView android:id="@+id/name" android:orientation="vertical">
android:textColor="@color/dashboard_black"
<TextView
android:id="@+id/name"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"
<LinearLayout android:orientation="horizontal" android:textColor="?android:textColorPrimary"
tools:text="@string/validate_gpx_upload_name_pwd"/>
<LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
<ImageView android:id="@+id/points_icon" android:orientation="horizontal">
android:src="@drawable/ic_small_point"
android:layout_gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/points_count"
android:textColor="@color/dashboard_descr_colol"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<ImageView android:id="@+id/distance_icon" <ImageView
android:src="@drawable/ic_small_distance" android:id="@+id/points_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:src="@drawable/ic_small_point"/>
<TextView
android:id="@+id/points_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/icon_color_light"/>
<ImageView
android:id="@+id/distance_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/dashPluginMargin" android:layout_marginLeft="@dimen/dashPluginMargin"
android:layout_gravity="center_vertical" android:src="@drawable/ic_small_distance"/>
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/distance"
android:textColor="@color/dashboard_descr_colol"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<ImageView android:id="@+id/time_icon" <TextView
android:src="@drawable/ic_small_time" android:id="@+id/distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/icon_color_light"/>
<ImageView
android:id="@+id/time_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:src="@drawable/ic_small_time"/>
<TextView
android:id="@+id/time"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"
<TextView android:id="@+id/time" android:textColor="@color/icon_color_light"/>
android:textColor="@color/dashboard_descr_colol"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
<ImageView android:id="@+id/stop" <ImageButton
android:visibility="gone" android:id="@+id/stop"
android:layout_gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<ImageView android:id="@+id/show_on_map"
android:layout_gravity="center_vertical"
android:layout_width="@dimen/dashListItemHeight" android:layout_width="@dimen/dashListItemHeight"
android:layout_height="@dimen/dashListItemHeight"/> android:layout_height="@dimen/dashListItemHeight"
android:layout_gravity="center_vertical"
android:layout_marginRight="@dimen/favorites_icon_right_margin"
android:background="?attr/options_button_background"
android:src="@drawable/ic_action_rec_stop"
android:visibility="gone"
tools:visibility="visible"/>
<ImageButton
android:id="@+id/show_on_map"
android:layout_width="@dimen/dashListItemHeight"
android:layout_height="@dimen/dashListItemHeight"
android:layout_gravity="center_vertical"
android:background="?attr/options_button_background"
android:src="@drawable/ic_action_gsave_dark"/>
</LinearLayout> </LinearLayout>

View file

@ -22,7 +22,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:maxLines="3" android:maxLines="3"
android:textColor="@color/dashboard_descr_colol" android:textColor="@color/icon_color_light"
android:text="@string/loading_data" android:text="@string/loading_data"
android:textSize="@dimen/dashProgressTextSize"/> android:textSize="@dimen/dashProgressTextSize"/>
</LinearLayout> </LinearLayout>

View file

@ -60,13 +60,13 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"/>
<!--<fragment--> <fragment
<!--xmlns:android="http://schemas.android.com/apk/res/android"--> xmlns:android="http://schemas.android.com/apk/res/android"
<!--android:id="@+id/TracksFragment"--> android:id="@+id/TracksFragment"
<!--android:name="net.osmand.plus.dashboard.DashTrackFragment"--> android:name="net.osmand.plus.monitoring.DashTrackFragment"
<!--android:layout_marginTop="@dimen/dashCardMargin"--> android:layout_marginTop="@dimen/dashCardMargin"
<!--android:layout_width="match_parent"--> android:layout_width="match_parent"
<!--android:layout_height="wrap_content"/>--> android:layout_height="wrap_content"/>
<!--<fragment--> <!--<fragment-->
<!--xmlns:android="http://schemas.android.com/apk/res/android"--> <!--xmlns:android="http://schemas.android.com/apk/res/android"-->

View file

@ -84,7 +84,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginLeft="4dp" android:layout_marginLeft="4dp"
android:textColor="@color/dashboard_descr_colol" android:textColor="@color/icon_color_light"
android:textSize="@dimen/showAllButtonTextSize"/> android:textSize="@dimen/showAllButtonTextSize"/>
</LinearLayout> </LinearLayout>

View file

@ -15,8 +15,7 @@
android:focusable="false" android:focusable="false"
android:visibility="gone" android:visibility="gone"
android:layout_marginRight="@dimen/local_index_check_right_margin" android:layout_marginRight="@dimen/local_index_check_right_margin"
android:layout_marginTop="@dimen/favorites_icon_top_margin" android:layout_marginTop="@dimen/favorites_icon_top_margin"/>
/>
<ImageView <ImageView
android:id="@+id/icon" android:id="@+id/icon"

View file

@ -5,9 +5,19 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/expandable_list_item_background" android:background="?attr/expandable_list_item_background"
android:minHeight="@dimen/list_item_height" android:minHeight="@dimen/list_item_height"
android:orientation="horizontal" android:orientation="vertical"
android:paddingLeft="@dimen/list_content_padding"> android:paddingLeft="@dimen/list_content_padding">
<View
android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:visibility="gone"
android:background="?attr/dashboard_divider"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<CheckBox <CheckBox
android:id="@+id/check_local_index" android:id="@+id/check_local_index"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -64,4 +74,16 @@
android:focusable="false" android:focusable="false"
android:src="?attr/list_settings_icon"/> android:src="?attr/list_settings_icon"/>
<ImageButton
android:id="@+id/play"
android:layout_width="@dimen/dashListItemHeight"
android:layout_height="@dimen/dashListItemHeight"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/dashFavIconMargin"
android:background="?attr/dashboard_button"
android:src="@drawable/ic_play_light"/>
</LinearLayout>
</LinearLayout> </LinearLayout>

View file

@ -7,31 +7,67 @@
android:orientation="horizontal" android:orientation="horizontal"
android:paddingBottom="5dp" android:paddingBottom="5dp"
android:paddingLeft="@dimen/list_content_padding" android:paddingLeft="@dimen/list_content_padding"
android:paddingRight="@dimen/list_content_padding"
android:paddingTop="5dp"> android:paddingTop="5dp">
<TextView <ImageView
android:id="@+id/label" android:id="@+id/icon"
style="@style/ListText" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/favorites_icon_right_margin"
android:layout_marginTop="@dimen/favorites_icon_top_margin"
android:focusable="false"
android:src="@drawable/ic_sdcard"/>
<LinearLayout
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginRight="3dp"
android:layout_weight="1" android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="1" android:maxLines="1"
android:textColor="?android:textColorPrimary" android:textColor="?android:textColorPrimary"
android:textSize="@dimen/dashFavNameTextSize"
tools:text="@string/lorem_ipsum"/> tools:text="@string/lorem_ipsum"/>
<ImageButton <LinearLayout
android:id="@+id/remove"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:orientation="horizontal">
android:background="?attr/reset_image"
android:contentDescription="@string/default_buttons_delete" <ImageView
android:paddingLeft="2dp" android:id="@+id/direction"
android:paddingRight="2dp" android:layout_width="@dimen/dashFavDirectionSize"
android:paddingTop="2dp"/> android:layout_height="@dimen/dashFavDirectionSize"
android:layout_gravity="center_vertical"/>
<TextView
android:id="@+id/distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/showAllButtonTextSize"
tools:text="100500 km"/>
</LinearLayout>
</LinearLayout>
<ImageButton
android:id="@+id/options"
android:layout_width="@dimen/list_item_height"
android:layout_height="@dimen/list_item_height"
android:layout_gravity="center_vertical"
android:background="?attr/options_button_background"
android:focusable="false"
android:src="?attr/list_settings_icon"/>
</LinearLayout> </LinearLayout>

View file

@ -20,7 +20,9 @@
<color name="search_background_dark">#292f33</color> <color name="search_background_dark">#292f33</color>
<color name="dashboard_descr_colol">#727272</color> <color name="icon_color_light">#727272</color>
<color name="dashboard_gpx_on_map">#448AFF</color>
<color name="dashboard_background">#eaeaea</color> <color name="dashboard_background">#eaeaea</color>
<color name="dashboard_divider_light">#F0F0F0</color> <color name="dashboard_divider_light">#F0F0F0</color>
<color name="dashboard_divider_dark">#3d474c</color> <color name="dashboard_divider_dark">#3d474c</color>

View file

@ -9,7 +9,10 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). 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 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="rename_failed">Rename failed.</string>
<string name="days_behind">days behind</string> <string name="days_behind">days behind</string>
<string name="currently_recording_track">Currently recording track</string>
<string name="back_to_map">Back to map</string>
<string name="plugin_nautical_descr1">Activating this view changes the map style to Nautical, thus showing all nautical navigation marks and chart symbols.</string> <string name="plugin_nautical_descr1">Activating this view changes the map style to Nautical, thus showing all nautical navigation marks and chart symbols.</string>
<string name="plugin_nautical_descr2">A map file containing all nautical symbols globally is available as one single download called \'World seamarks\'.</string> <string name="plugin_nautical_descr2">A map file containing all nautical symbols globally is available as one single download called \'World seamarks\'.</string>
<string name="plugin_nautical_descr3">This view can be reverted by either de-activating it again here, or by changing the \'Map style\' under \'Configure map\' as desired.</string> <string name="plugin_nautical_descr3">This view can be reverted by either de-activating it again here, or by changing the \'Map style\' under \'Configure map\' as desired.</string>

View file

@ -48,6 +48,7 @@ public abstract class ActionBarPreferenceActivity extends PreferenceActivity {
} }
tb.setClickable(true); tb.setClickable(true);
Drawable back = getResources().getDrawable(R.drawable.abc_ic_ab_back_mtrl_am_alpha); Drawable back = getResources().getDrawable(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
back.mutate();
back.setColorFilter(0xffffffff, PorterDuff.Mode.MULTIPLY); back.setColorFilter(0xffffffff, PorterDuff.Mode.MULTIPLY);
tb.setNavigationIcon(back); tb.setNavigationIcon(back);
tb.setBackgroundColor(getResources().getColor(getResIdFromAttribute(this, R.attr.pstsTabBackground))); tb.setBackgroundColor(getResources().getColor(getResIdFromAttribute(this, R.attr.pstsTabBackground)));

View file

@ -20,6 +20,8 @@ import net.osmand.plus.GPXUtilities;
import net.osmand.plus.GPXUtilities.GPXFile; import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.GPXUtilities.WptPt; import net.osmand.plus.GPXUtilities.WptPt;
import net.osmand.plus.GpxSelectionHelper; import net.osmand.plus.GpxSelectionHelper;
import net.osmand.plus.NavigationService;
import net.osmand.plus.OsmAndTaskManager;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
@ -27,8 +29,10 @@ import net.osmand.plus.R;
import net.osmand.plus.dialogs.DirectionsDialogs; import net.osmand.plus.dialogs.DirectionsDialogs;
import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.helpers.GpxUiHelper;
import net.osmand.plus.helpers.ScreenOrientationHelper; import net.osmand.plus.helpers.ScreenOrientationHelper;
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
import net.osmand.plus.osmedit.OsmEditingPlugin; import net.osmand.plus.osmedit.OsmEditingPlugin;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.AlertDialog.Builder; import android.app.AlertDialog.Builder;
@ -36,9 +40,12 @@ import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.res.TypedArray; import android.content.res.TypedArray;
import android.graphics.PorterDuff;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.net.Uri; import android.net.Uri;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.support.v4.view.MenuItemCompat; import android.support.v4.view.MenuItemCompat;
import android.support.v7.app.ActionBarActivity; import android.support.v7.app.ActionBarActivity;
@ -109,6 +116,9 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
asyncLoader = new LoadGpxTask(); asyncLoader = new LoadGpxTask();
asyncLoader.execute(getActivity()); asyncLoader.execute(getActivity());
} }
updateCurrentTrack(getView());
} }
@Override @Override
@ -119,6 +129,100 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
} }
} }
private void updateCurrentTrack(View v) {
if (v == null) {
return;
}
if (app.getSettings().SAVE_GLOBAL_TRACK_TO_GPX.get()) {
GpxSelectionHelper.SelectedGpxFile currentTrack = savingTrackHelper.getCurrentTrack();
v.findViewById(R.id.current_track).setVisibility(View.VISIBLE);
String description = GpxUiHelper.getDescription(getMyApplication(), currentTrack.getGpxFile(), null, true);
int startindex = description.indexOf(">");
int endindex = description.indexOf("</font>");
String distance = description.substring(startindex + 1, endindex);
String points = String.valueOf(currentTrack.getGpxFile().points.size());
((TextView) v.findViewById(R.id.points_count)).setText(points);
((TextView) v.findViewById(R.id.distance)).setText(distance);
} else {
v.findViewById(R.id.current_track).setVisibility(View.GONE);
}
}
@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);
}
((TextView) v.findViewById(R.id.name)).setText(R.string.currently_recording_track);
v.findViewById(R.id.time_icon).setVisibility(View.GONE);
createCurrentTrackView(v, getMyApplication());
v.findViewById(R.id.map_btn).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
MapActivity.launchMapActivityMoveToTop(getActivity());
}
});
return v;
}
public static void createCurrentTrackView(View v, final OsmandApplication app) {
Drawable icon = app.getResources().getDrawable(R.drawable.ic_action_rec_stop);
icon.mutate();
boolean light = app.getSettings().isLightContent();
if (light) {
icon.setColorFilter(0xff727272, PorterDuff.Mode.MULTIPLY);
}
ImageButton stop = ((ImageButton) v.findViewById(R.id.stop));
stop.setImageDrawable(icon);
stop.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Runnable run = new Runnable() {
@Override
public void run() {
final OsmandMonitoringPlugin plugin = OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class);
plugin.stopRecording();
}
};
run.run();
}
});
stop.setVisibility(View.VISIBLE);
icon = app.getResources().getDrawable(R.drawable.ic_action_gsave_dark);
icon.mutate();
if (light) {
icon.setColorFilter(0xff727272, PorterDuff.Mode.MULTIPLY);
}
ImageButton save = ((ImageButton) v.findViewById(R.id.show_on_map));
save.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
save.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Runnable run = new Runnable() {
@Override
public void run() {
final OsmandMonitoringPlugin plugin = OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class);
plugin.saveCurrentTrack();
}
};
run.run();
}
});
v.findViewById(R.id.divider).setVisibility(View.GONE);
save.setImageDrawable(icon);
}
@Override @Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
@ -168,7 +272,6 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
} }
optionsMenuAdapter = new ContextMenuAdapter(getActivity()); optionsMenuAdapter = new ContextMenuAdapter(getActivity());
OnContextMenuClick listener = new OnContextMenuClick() { OnContextMenuClick listener = new OnContextMenuClick() {
@Override @Override
@ -192,7 +295,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
} }
}; };
optionsMenuAdapter.item(R.string.show_gpx_route) optionsMenuAdapter.item(R.string.show_gpx_route)
.icons(R.drawable.ic_action_map_marker_dark, R.drawable.ic_action_map_marker_dark).listen(listener).reg(); .icons(R.drawable.ic_show_on_map, R.drawable.ic_show_on_map).listen(listener).reg();
optionsMenuAdapter.item(R.string.local_index_mi_delete) optionsMenuAdapter.item(R.string.local_index_mi_delete)
.icons(R.drawable.ic_action_delete_dark, R.drawable.ic_action_delete_dark).listen(listener).reg(); .icons(R.drawable.ic_action_delete_dark, R.drawable.ic_action_delete_dark).listen(listener).reg();
optionsMenuAdapter.item(R.string.local_index_mi_reload) optionsMenuAdapter.item(R.string.local_index_mi_reload)
@ -499,26 +602,6 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
} }
} }
private void showContextMenu(final GpxInfo info) {
Builder builder = new AlertDialog.Builder(getActivity());
final ContextMenuAdapter adapter = new ContextMenuAdapter(getActivity());
basicFileOperation(info, adapter);
String[] values = adapter.getItemNames();
builder.setItems(values, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
OnContextMenuClick clk = adapter.getClickAdapter(which);
if (clk != null) {
clk.onContextMenuClick(null, adapter.getElementId(which), which, false);
}
}
});
builder.show();
}
public class LoadGpxTask extends AsyncTask<Activity, GpxInfo, List<GpxInfo>> { public class LoadGpxTask extends AsyncTask<Activity, GpxInfo, List<GpxInfo>> {
private List<GpxInfo> result; private List<GpxInfo> result;
@ -882,8 +965,13 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
boolean light = getMyApplication().getSettings().isLightContent(); boolean light = getMyApplication().getSettings().isLightContent();
final PopupMenu optionsMenu = new PopupMenu(getActivity(), v); final PopupMenu optionsMenu = new PopupMenu(getActivity(), v);
DirectionsDialogs.setupPopUpMenuIcon(optionsMenu); DirectionsDialogs.setupPopUpMenuIcon(optionsMenu);
Drawable showIcon = getResources().getDrawable(R.drawable.ic_show_on_map);
if (light) {
showIcon.mutate();
showIcon.setColorFilter(getResources().getColor(R.color.icon_color_light), PorterDuff.Mode.MULTIPLY);
}
MenuItem item = optionsMenu.getMenu().add(R.string.show_gpx_route) MenuItem item = optionsMenu.getMenu().add(R.string.show_gpx_route)
.setIcon(light ? R.drawable.ic_action_map_marker_light : R.drawable.ic_action_map_marker_dark); .setIcon(showIcon);
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override @Override
public boolean onMenuItemClick(MenuItem item) { public boolean onMenuItemClick(MenuItem item) {

View file

@ -38,10 +38,12 @@ public class FavoritesActivity extends TabActivity {
// private static final String FAVOURITES_INFO = "FAVOURITES_INFO"; // private static final String FAVOURITES_INFO = "FAVOURITES_INFO";
private static final String TRACKS = "TRACKS"; private static final String TRACKS = "TRACKS";
// private static final String SELECTED_TRACK = "SELECTED_TRACK"; // private static final String SELECTED_TRACK = "SELECTED_TRACK";
// public static int FAVORITES_TAB = 0; public static int FAVORITES_TAB = 0;
// public static int GPX_TAB = 1; public static int GPX_TAB = 1;
// public static int SELECTED_GPX_TAB = 2; public static int SELECTED_GPX_TAB = 2;
// public static String TAB_PARAM = "TAB_PARAM"; public static int NOTES_TAB = 3;
public static int OSM_EDITS_TAB = 4;
public static String TAB_PARAM = "TAB_PARAM";
protected List<WeakReference<Fragment>> fragList = new ArrayList<WeakReference<Fragment>>(); protected List<WeakReference<Fragment>> fragList = new ArrayList<WeakReference<Fragment>>();
@Override @Override
@ -78,10 +80,18 @@ public class FavoritesActivity extends TabActivity {
OsmandPlugin.addMyPlacesTabPlugins(this, mTabs, getIntent()); OsmandPlugin.addMyPlacesTabPlugins(this, mTabs, getIntent());
Integer tab = settings.FAVORITES_TAB.get(); Integer tab = settings.FAVORITES_TAB.get();
if (tab == NOTES_TAB) {
tab = mTabs.size() -1;
} else if (tab == OSM_EDITS_TAB) {
//TODO implement method of counting position for other plugins
}
setViewPagerAdapter(mViewPager, mTabs); setViewPagerAdapter(mViewPager, mTabs);
mSlidingTabLayout.setViewPager(mViewPager); mSlidingTabLayout.setViewPager(mViewPager);
if (tab > mTabs.size() - 1){
tab = 0;
}
mViewPager.setCurrentItem(tab); mViewPager.setCurrentItem(tab);
updateSelectedTracks(); updateSelectedTracks();
// setupHomeButton(); // setupHomeButton();

View file

@ -21,7 +21,6 @@ import net.osmand.plus.activities.search.SearchActivity;
import net.osmand.plus.activities.search.SearchActivity.SearchActivityChild; import net.osmand.plus.activities.search.SearchActivity.SearchActivityChild;
import net.osmand.plus.base.FavoriteImageDrawable; import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.dialogs.DirectionsDialogs; import net.osmand.plus.dialogs.DirectionsDialogs;
import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils; import net.osmand.util.MapUtils;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
@ -156,7 +155,7 @@ public class FavoritesListFragment extends ListFragment implements SearchActivit
} }
public FavouritesAdapter(Activity activity, List<FavouritePoint> list) { public FavouritesAdapter(Activity activity, List<FavouritePoint> list) {
super(activity, R.layout.favourites_list_item, list); super(activity, R.layout.favorites_list_item, list);
this.activity = activity; this.activity = activity;
this.app = ((OsmandApplication) activity.getApplication()); this.app = ((OsmandApplication) activity.getApplication());
boolean light = app.getSettings().isLightContent(); boolean light = app.getSettings().isLightContent();
@ -178,7 +177,7 @@ public class FavoritesListFragment extends ListFragment implements SearchActivit
View row = convertView; View row = convertView;
if (row == null) { if (row == null) {
LayoutInflater inflater = activity.getLayoutInflater(); LayoutInflater inflater = activity.getLayoutInflater();
row = inflater.inflate(R.layout.favourites_list_item, parent, false); row = inflater.inflate(R.layout.favorites_list_item, parent, false);
} }
TextView name = (TextView) row.findViewById(R.id.favourite_label); TextView name = (TextView) row.findViewById(R.id.favourite_label);

View file

@ -204,7 +204,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
private boolean editPoint(final FavouritePoint point) { private boolean editPoint(final FavouritePoint point) {
Builder builder = new AlertDialog.Builder(getActivity()); Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(R.string.favourites_context_menu_edit); builder.setTitle(R.string.favourites_context_menu_edit);
final View v = getActivity().getLayoutInflater().inflate(R.layout.favourite_edit_dialog, final View v = getActivity().getLayoutInflater().inflate(R.layout.favorite_edit_dialog,
getExpandableListView(), false); getExpandableListView(), false);
final AutoCompleteTextView cat = (AutoCompleteTextView) v.findViewById(R.id.Category); final AutoCompleteTextView cat = (AutoCompleteTextView) v.findViewById(R.id.Category);
final EditText editText = (EditText) v.findViewById(R.id.Name); final EditText editText = (EditText) v.findViewById(R.id.Name);
@ -762,7 +762,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
View row = convertView; View row = convertView;
if (row == null) { if (row == null) {
LayoutInflater inflater = getActivity().getLayoutInflater(); LayoutInflater inflater = getActivity().getLayoutInflater();
row = inflater.inflate(R.layout.favourites_list_item, parent, false); row = inflater.inflate(R.layout.favorites_list_item, parent, false);
} }
TextView name = (TextView) row.findViewById(R.id.favourite_label); TextView name = (TextView) row.findViewById(R.id.favourite_label);

View file

@ -21,8 +21,8 @@ public abstract class OsmandExpandableListFragment extends Fragment
implements OnChildClickListener { implements OnChildClickListener {
private ExpandableListView listView; protected ExpandableListView listView;
private ExpandableListAdapter adapter; protected ExpandableListAdapter adapter;
public OsmandApplication getMyApplication() { public OsmandApplication getMyApplication() {

View file

@ -10,11 +10,19 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.search.SearchActivity.SearchActivityChild; import net.osmand.plus.activities.search.SearchActivity.SearchActivityChild;
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
import net.osmand.plus.dialogs.DirectionsDialogs; import net.osmand.plus.dialogs.DirectionsDialogs;
import net.osmand.plus.helpers.SearchHistoryHelper; import net.osmand.plus.helpers.SearchHistoryHelper;
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry; import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
import net.osmand.util.MapUtils; import net.osmand.util.MapUtils;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.media.Image;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentActivity;
import android.support.v4.app.ListFragment; import android.support.v4.app.ListFragment;
@ -24,11 +32,13 @@ import android.text.style.ForegroundColorSpan;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.Button; import android.widget.Button;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.TextView.BufferType; import android.widget.TextView.BufferType;
@ -95,7 +105,9 @@ public class SearchHistoryFragment extends ListFragment implements SearchActivit
location = ((OsmandApplication) activity.getApplication()).getSettings().getLastKnownMapLocation(); location = ((OsmandApplication) activity.getApplication()).getSettings().getLastKnownMapLocation();
} }
historyAdapter.clear(); historyAdapter.clear();
historyAdapter.addAll(helper.getHistoryEntries()); for(HistoryEntry entry : helper.getHistoryEntries()){
historyAdapter.add(entry);
}
locationUpdate(location); locationUpdate(location);
clearButton.setVisibility(historyAdapter.isEmpty() ? View.GONE : View.VISIBLE); clearButton.setVisibility(historyAdapter.isEmpty() ? View.GONE : View.VISIBLE);
@ -127,6 +139,7 @@ public class SearchHistoryFragment extends ListFragment implements SearchActivit
class HistoryAdapter extends ArrayAdapter<HistoryEntry> { class HistoryAdapter extends ArrayAdapter<HistoryEntry> {
private LatLon location; private LatLon location;
Drawable arrowImage;
public void updateLocation(LatLon l) { public void updateLocation(LatLon l) {
location = l; location = l;
@ -135,6 +148,14 @@ public class SearchHistoryFragment extends ListFragment implements SearchActivit
public HistoryAdapter(List<HistoryEntry> list) { public HistoryAdapter(List<HistoryEntry> list) {
super(getActivity(), R.layout.search_history_list_item, list); super(getActivity(), R.layout.search_history_list_item, list);
arrowImage = getResources().getDrawable(R.drawable.ic_destination_arrow_white);
arrowImage.mutate();
boolean light = getMyApplication().getSettings().isLightContent();
if (light) {
arrowImage.setColorFilter(getResources().getColor(R.color.color_distance), PorterDuff.Mode.MULTIPLY);
} else {
arrowImage.setColorFilter(getResources().getColor(R.color.color_distance), PorterDuff.Mode.MULTIPLY);
}
} }
@Override @Override
@ -144,33 +165,28 @@ public class SearchHistoryFragment extends ListFragment implements SearchActivit
LayoutInflater inflater = getActivity().getLayoutInflater(); LayoutInflater inflater = getActivity().getLayoutInflater();
row = inflater.inflate(R.layout.search_history_list_item, parent, false); row = inflater.inflate(R.layout.search_history_list_item, parent, false);
} }
TextView label = (TextView) row.findViewById(R.id.label); TextView nameText = (TextView) row.findViewById(R.id.name);
TextView distanceText = (TextView) row.findViewById(R.id.distance);
String distance = ""; String distance = "";
ImageButton icon = (ImageButton) row.findViewById(R.id.remove); ImageView arrow = (ImageView) row.findViewById(R.id.direction);
arrow.setImageDrawable(arrowImage);
ImageButton options = (ImageButton) row.findViewById(R.id.options);
final HistoryEntry model = getItem(position); final HistoryEntry model = getItem(position);
if (location != null) { if (location != null) {
int dist = (int) (MapUtils.getDistance(location, model.getLat(), model.getLon())); int dist = (int) (MapUtils.getDistance(location, model.getLat(), model.getLon()));
distance = OsmAndFormatter.getFormattedDistance(dist, (OsmandApplication) getActivity().getApplication()) + " "; distance = OsmAndFormatter.getFormattedDistance(dist, (OsmandApplication) getActivity().getApplication()) + " ";
} }
String rnk = MessageFormat.format(" {0,number,#.##E00} ", ((float)model.getRank(System.currentTimeMillis()))); distanceText.setText(distance);
label.setText(distance + rnk + model.getName().getName(), BufferType.SPANNABLE); nameText.setText(model.getName().getName(), BufferType.SPANNABLE);
((Spannable) label.getText()).setSpan(new ForegroundColorSpan(getResources().getColor(R.color.color_distance)), 0, distance.length(), 0);
icon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
helper.remove(model);
historyAdapter.remove(model);
}
}); options.setOnClickListener(new View.OnClickListener() {
View.OnClickListener clickListener = new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
selectModel(model, v); selectModel(model, v);
} }
};
label.setOnClickListener(clickListener); });
return row; return row;
} }
} }
@ -181,4 +197,8 @@ public class SearchHistoryFragment extends ListFragment implements SearchActivit
((SearchActivity) getActivity()).getClearToolbar(false); ((SearchActivity) getActivity()).getClearToolbar(false);
} }
} }
public OsmandApplication getMyApplication() {
return (OsmandApplication) getActivity().getApplication();
}
} }

View file

@ -67,6 +67,7 @@ import android.media.MediaRecorder;
import android.media.SoundPool; import android.media.SoundPool;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Environment;
import android.provider.MediaStore; import android.provider.MediaStore;
import android.view.Display; import android.view.Display;
import android.view.KeyEvent; import android.view.KeyEvent;
@ -138,9 +139,8 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
this.file = f; this.file = f;
} }
public File file; private File file;
private String name;
private double lat; private double lat;
private double lon; private double lon;
private long duration = -1; private long duration = -1;
@ -172,12 +172,26 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
} }
} }
public void setName(String name) { public File getFile() {
this.name = name; return file;
}
public boolean setName(String name) {
int index = file.getAbsolutePath().lastIndexOf("/") + 1;
if (index < 0){
return false;
}
File directory = new File(file.getAbsolutePath().substring(0, index));
File to = new File(directory, name.trim());
if (file.renameTo(to)){
file = to;
return true;
}
return false;
} }
public String getName() { public String getName() {
return name; return file.getName();
} }
public boolean isPhoto() { public boolean isPhoto() {
@ -289,13 +303,12 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
} }
public String getSmallDescription(Context ctx) { public String getSmallDescription(Context ctx) {
String nm = name == null ? "" : name;
String time = AndroidUtils.formatDateTime(ctx,file.lastModified()); String time = AndroidUtils.formatDateTime(ctx,file.lastModified());
if (isPhoto()) { if (isPhoto()) {
return ctx.getString(R.string.recording_photo_description, nm, time).trim(); return ctx.getString(R.string.recording_photo_description, "", time).trim();
} }
return ctx.getString(R.string.recording_description, nm, "", time).trim(); return ctx.getString(R.string.recording_description, "", "", time).trim();
} }
private String getDuration(Context ctx) { private String getDuration(Context ctx) {
@ -934,7 +947,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
if (getAllRecordings().size() > 0) { if (getAllRecordings().size() > 0) {
mTabs.add(favoritesActivity.getTabIndicator(R.string.notes, NotesFragment.class)); mTabs.add(favoritesActivity.getTabIndicator(R.string.notes, NotesFragment.class));
if (intent != null && "AUDIO".equals(intent.getStringExtra("TAB"))) { if (intent != null && "AUDIO".equals(intent.getStringExtra("TAB"))) {
app.getSettings().FAVORITES_TAB.set(mTabs.size() - 1); app.getSettings().FAVORITES_TAB.set(FavoritesActivity.NOTES_TAB);
} }
} }
} }

View file

@ -49,6 +49,7 @@ public class DashAudioVideoNotesFragment extends DashBaseFragment {
final Intent favorites = new Intent(activity, fa); final Intent favorites = new Intent(activity, fa);
favorites.putExtra("TAB", "AUDIO"); favorites.putExtra("TAB", "AUDIO");
favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
getMyApplication().getSettings().FAVORITES_TAB.set(FavoritesActivity.NOTES_TAB);
activity.startActivity(favorites); activity.startActivity(favorites);
} }
}); });
@ -94,15 +95,23 @@ public class DashAudioVideoNotesFragment extends DashBaseFragment {
for (final AudioVideoNotesPlugin.Recording recording : notes){ for (final AudioVideoNotesPlugin.Recording recording : notes){
LayoutInflater inflater = getActivity().getLayoutInflater(); LayoutInflater inflater = getActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.dash_audio_video_notes_item, null, false); View view = inflater.inflate(R.layout.note, null, false);
getNoteView(recording, view, getActivity(), plugin); getNoteView(recording, view, getActivity(), plugin);
view.findViewById(R.id.play).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
plugin.playRecording(getActivity(), recording);
}
});
view.findViewById(R.id.options).setVisibility(View.GONE);
view.findViewById(R.id.divider).setVisibility(View.VISIBLE);
view.setOnClickListener(new View.OnClickListener() { view.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
getMyApplication().getSettings().setMapLocationToShow(recording.getLatitude(), recording.getLongitude(), 15, getMyApplication().getSettings().setMapLocationToShow(recording.getLatitude(), recording.getLongitude(), 15,
new PointDescription(PointDescription.POINT_TYPE_NOTE, new PointDescription(PointDescription.POINT_TYPE_NOTE,
!Algorithms.isEmpty(recording.getName())? recording.getName() : recording.getDescription(getActivity())), true, (recording.getName() != null) ? recording.getName() : recording.getDescription(getActivity())), true,
recording); //$NON-NLS-1$ recording); //$NON-NLS-1$
MapActivity.launchMapActivityMoveToTop(getActivity()); MapActivity.launchMapActivityMoveToTop(getActivity());
} }
@ -113,13 +122,18 @@ public class DashAudioVideoNotesFragment extends DashBaseFragment {
public static void getNoteView(final AudioVideoNotesPlugin.Recording recording, View view, public static void getNoteView(final AudioVideoNotesPlugin.Recording recording, View view,
final Context ctx, final AudioVideoNotesPlugin plugin) { final Context ctx, final AudioVideoNotesPlugin plugin) {
if (recording.getName() != null){ String name = recording.getName();
((TextView) view.findViewById(R.id.name)).setText(recording.getName()); TextView nameText = ((TextView) view.findViewById(R.id.name));
((TextView) view.findViewById(R.id.descr)).setText(recording.getDescription(ctx)); if (name != null) {
} else { nameText.setText(name);
((TextView) view.findViewById(R.id.name)).setText(recording.getDescription(ctx)); } else if (recording.isAudio()) {
view.findViewById(R.id.descr).setVisibility(View.GONE); nameText.setText(R.string.audio);
} else if (recording.isVideo()) {
nameText.setText(R.string.video);
} else if (recording.isPhoto()) {
nameText.setText(R.string.photo);
} }
((TextView) view.findViewById(R.id.descr)).setText(recording.getDescription(ctx));
ImageView icon = (ImageView) view.findViewById(R.id.icon); ImageView icon = (ImageView) view.findViewById(R.id.icon);
if (recording.isAudio()) { if (recording.isAudio()) {
@ -130,12 +144,6 @@ public class DashAudioVideoNotesFragment extends DashBaseFragment {
icon.setImageResource(R.drawable.ic_type_img); icon.setImageResource(R.drawable.ic_type_img);
} }
view.findViewById(R.id.play).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
plugin.playRecording(ctx, recording);
}
});
} }
} }

View file

@ -28,6 +28,7 @@ import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.audionotes.AudioVideoNotesPlugin.Recording; import net.osmand.plus.audionotes.AudioVideoNotesPlugin.Recording;
import net.osmand.plus.dialogs.DirectionsDialogs; import net.osmand.plus.dialogs.DirectionsDialogs;
import android.support.v4.app.ListFragment; import android.support.v4.app.ListFragment;
import android.widget.Toast;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -89,27 +90,8 @@ public class NotesFragment extends ListFragment {
} }
final AudioVideoNotesPlugin.Recording recording = getItem(position); final AudioVideoNotesPlugin.Recording recording = getItem(position);
String name = recording.getName(); DashAudioVideoNotesFragment.getNoteView(recording, row, getActivity(), plugin);
TextView nameText = ((TextView) row.findViewById(R.id.name)); row.findViewById(R.id.play).setVisibility(View.GONE);
if (name != null) {
nameText.setText(name);
} else if (recording.isAudio()) {
nameText.setText(R.string.audio);
} else if (recording.isVideo()) {
nameText.setText(R.string.video);
} else if (recording.isPhoto()) {
nameText.setText(R.string.photo);
}
((TextView) row.findViewById(R.id.descr)).setText(recording.getDescription(getActivity()));
ImageView icon = (ImageView) row.findViewById(R.id.icon);
if (recording.isAudio()) {
icon.setImageResource(R.drawable.ic_type_audio);
} else if (recording.isVideo()) {
icon.setImageResource(R.drawable.ic_type_video);
} else {
icon.setImageResource(R.drawable.ic_type_img);
}
ImageButton options = (ImageButton) row.findViewById(R.id.options); ImageButton options = (ImageButton) row.findViewById(R.id.options);
options.setOnClickListener(new View.OnClickListener() { options.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -173,15 +155,15 @@ public class NotesFragment extends ListFragment {
public boolean onMenuItemClick(MenuItem item) { public boolean onMenuItemClick(MenuItem item) {
Intent sharingIntent = new Intent(Intent.ACTION_SEND); Intent sharingIntent = new Intent(Intent.ACTION_SEND);
if (recording.isPhoto()) { if (recording.isPhoto()) {
Uri screenshotUri = Uri.parse(recording.file.getAbsolutePath()); Uri screenshotUri = Uri.parse(recording.getFile().getAbsolutePath());
sharingIntent.setType("image/*"); sharingIntent.setType("image/*");
sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri); sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
} else if (recording.isAudio()) { } else if (recording.isAudio()) {
Uri audioUri = Uri.parse(recording.file.getAbsolutePath()); Uri audioUri = Uri.parse(recording.getFile().getAbsolutePath());
sharingIntent.setType("audio/*"); sharingIntent.setType("audio/*");
sharingIntent.putExtra(Intent.EXTRA_STREAM, audioUri); sharingIntent.putExtra(Intent.EXTRA_STREAM, audioUri);
} else if (recording.isVideo()) { } else if (recording.isVideo()) {
Uri videoUri = Uri.parse(recording.file.getAbsolutePath()); Uri videoUri = Uri.parse(recording.getFile().getAbsolutePath());
sharingIntent.setType("video/*"); sharingIntent.setType("video/*");
sharingIntent.putExtra(Intent.EXTRA_STREAM, videoUri); sharingIntent.putExtra(Intent.EXTRA_STREAM, videoUri);
} }
@ -229,12 +211,23 @@ public class NotesFragment extends ListFragment {
getListView(), false); getListView(), false);
final EditText editText = (EditText) v.findViewById(R.id.name); final EditText editText = (EditText) v.findViewById(R.id.name);
builder.setView(v); builder.setView(v);
editText.setText(recording.getName()); String fileName = recording.getName();
int extInd = recording.getName().lastIndexOf(".");
final String extension;
if (extInd >= 0){
extension = fileName.substring(extInd, fileName.length());
} else {
extension = "";
}
editText.setText(recording.getName().substring(0, extInd));
builder.setNegativeButton(R.string.default_buttons_cancel, null); builder.setNegativeButton(R.string.default_buttons_cancel, null);
builder.setPositiveButton(R.string.default_buttons_apply, new DialogInterface.OnClickListener() { builder.setPositiveButton(R.string.default_buttons_apply, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
recording.setName(editText.getText().toString()); if(!recording.setName(editText.getText().toString() + extension)) {
Toast.makeText(getActivity(),R.string.rename_failed,Toast.LENGTH_SHORT).show();
}
recording.setDescription(); recording.setDescription();
listAdapter.notifyDataSetInvalidated(); listAdapter.notifyDataSetInvalidated();
} }

View file

@ -13,6 +13,7 @@ import net.osmand.plus.FavouritesDbHelper;
import net.osmand.plus.OsmAndAppCustomization; import net.osmand.plus.OsmAndAppCustomization;
import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.FavoritesActivity;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.FavoriteImageDrawable; import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.dialogs.DirectionsDialogs; import net.osmand.plus.dialogs.DirectionsDialogs;
@ -56,6 +57,7 @@ public class DashFavoritesFragment extends DashLocationFragment implements Favou
OsmAndAppCustomization appCustomization = getMyApplication().getAppCustomization(); OsmAndAppCustomization appCustomization = getMyApplication().getAppCustomization();
final Intent favorites = new Intent(activity, appCustomization.getFavoritesActivity()); final Intent favorites = new Intent(activity, appCustomization.getFavoritesActivity());
favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
getMyApplication().getSettings().FAVORITES_TAB.set(FavoritesActivity.FAVORITES_TAB);
activity.startActivity(favorites); activity.startActivity(favorites);
} }
}); });

View file

@ -175,7 +175,7 @@ public class FavoriteDialogs {
public static Dialog createAddFavouriteDialog(final Activity activity, final Bundle args) { public static Dialog createAddFavouriteDialog(final Activity activity, final Bundle args) {
Builder builder = new AlertDialog.Builder(activity); Builder builder = new AlertDialog.Builder(activity);
builder.setTitle(R.string.favourites_context_menu_edit); builder.setTitle(R.string.favourites_context_menu_edit);
final View v = activity.getLayoutInflater().inflate(R.layout.favourite_edit_dialog, null, false); final View v = activity.getLayoutInflater().inflate(R.layout.favorite_edit_dialog, null, false);
final FavouritesDbHelper helper = ((OsmandApplication) activity.getApplication()).getFavorites(); final FavouritesDbHelper helper = ((OsmandApplication) activity.getApplication()).getFavorites();
builder.setView(v); builder.setView(v);
final EditText editText = (EditText) v.findViewById(R.id.Name); final EditText editText = (EditText) v.findViewById(R.id.Name);

View file

@ -4,22 +4,35 @@ import java.io.File;
import java.util.List; import java.util.List;
import net.osmand.IndexConstants; import net.osmand.IndexConstants;
import net.osmand.access.AccessibleToast;
import net.osmand.plus.GPXUtilities; import net.osmand.plus.GPXUtilities;
import net.osmand.plus.GpxSelectionHelper;
import net.osmand.plus.OsmAndAppCustomization; import net.osmand.plus.OsmAndAppCustomization;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.AvailableGPXFragment;
import net.osmand.plus.activities.FavoritesActivity;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.SavingTrackHelper;
import net.osmand.plus.dashboard.DashBaseFragment; import net.osmand.plus.dashboard.DashBaseFragment;
import net.osmand.plus.helpers.FontCache; import net.osmand.plus.helpers.FontCache;
import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.helpers.GpxUiHelper;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.graphics.PorterDuff;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Button; import android.widget.Button;
import android.widget.ImageButton;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
/** /**
* Created by Denis * Created by Denis
@ -42,6 +55,7 @@ public class DashTrackFragment extends DashBaseFragment {
Activity activity = getActivity(); Activity activity = getActivity();
OsmAndAppCustomization appCustomization = getMyApplication().getAppCustomization(); OsmAndAppCustomization appCustomization = getMyApplication().getAppCustomization();
final Intent favorites = new Intent(activity, appCustomization.getFavoritesActivity()); final Intent favorites = new Intent(activity, appCustomization.getFavoritesActivity());
getMyApplication().getSettings().FAVORITES_TAB.set(FavoritesActivity.GPX_TAB);
favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
activity.startActivity(favorites); activity.startActivity(favorites);
} }
@ -76,9 +90,31 @@ public class DashTrackFragment extends DashBaseFragment {
} }
} }
OsmandApplication app = getMyApplication();
SavingTrackHelper savingTrackHelper = app.getSavingTrackHelper();
if (app.getSettings().SAVE_GLOBAL_TRACK_TO_GPX.get()) {
list.remove(2);
LayoutInflater inflater = getActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.dash_gpx_track_item, null, false);
AvailableGPXFragment.createCurrentTrackView(view, app);
GpxSelectionHelper.SelectedGpxFile currentTrack = savingTrackHelper.getCurrentTrack();
((TextView)view.findViewById(R.id.name)).setText(R.string.currently_recording_track);
String description = GpxUiHelper.getDescription(getMyApplication(), currentTrack.getGpxFile(), null, true);
int startindex = description.indexOf(">");
int endindex = description.indexOf("</font>");
String distance = description.substring(startindex + 1, endindex);
String points = String.valueOf(currentTrack.getGpxFile().points.size());
((TextView) view.findViewById(R.id.points_count)).setText(points);
((TextView)view.findViewById(R.id.distance)).setText(distance);
tracks.addView(view);
}
for (String filename : list) { for (String filename : list) {
final File f = new File(dir, filename); final File f = new File(dir, filename);
GPXUtilities.GPXFile res = GPXUtilities.loadGPXFile(getMyApplication(), f); final GPXUtilities.GPXFile res = GPXUtilities.loadGPXFile(getMyApplication(), f);
LayoutInflater inflater = getActivity().getLayoutInflater(); LayoutInflater inflater = getActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.dash_gpx_track_item, null, false); View view = inflater.inflate(R.layout.dash_gpx_track_item, null, false);
((TextView) view.findViewById(R.id.name)).setText(filename); ((TextView) view.findViewById(R.id.name)).setText(filename);
@ -91,8 +127,48 @@ public class DashTrackFragment extends DashBaseFragment {
((TextView) view.findViewById(R.id.distance)). ((TextView) view.findViewById(R.id.distance)).
setText(distnace); setText(distnace);
view.findViewById(R.id.time_icon).setVisibility(View.GONE); view.findViewById(R.id.time_icon).setVisibility(View.GONE);
boolean light = getMyApplication().getSettings().isLightContent();
Drawable icon = getResources().getDrawable(R.drawable.ic_show_on_map);
GpxSelectionHelper gpxSelectionHelper = getMyApplication().getSelectedGpxHelper();
boolean isShowingOnMap = gpxSelectionHelper.getSelectedFileByName(filename) != null;
//setting proper icon color
if (isShowingOnMap) {
icon.mutate();
if (light) {
icon.setColorFilter(getResources().getColor(R.color.dashboard_gpx_on_map), PorterDuff.Mode.MULTIPLY);
} else {
icon.setColorFilter(getResources().getColor(R.color.color_distance), PorterDuff.Mode.MULTIPLY);
}
} else if (light) {
icon.mutate();
icon.setColorFilter(getResources().getColor(R.color.icon_color_light), PorterDuff.Mode.MULTIPLY);
}
final ImageButton showOnMap = (ImageButton) view.findViewById(R.id.show_on_map);
showOnMap.setImageDrawable(icon);
showOnMap.setVisibility(View.VISIBLE);
//view.findViewById(R.id.distance_icon).setVisibility(View.GONE); //view.findViewById(R.id.distance_icon).setVisibility(View.GONE);
view.findViewById(R.id.stop).setVisibility(View.GONE);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showOnMap(res);
}
});
tracks.addView(view); tracks.addView(view);
} }
} }
private void showOnMap(GPXUtilities.GPXFile file){
if (file.isEmpty()) {
AccessibleToast.makeText(getActivity(), R.string.gpx_file_is_empty, Toast.LENGTH_LONG).show();
return;
}
OsmandSettings settings = getMyApplication().getSettings();
settings.setMapLocationToShow(file.getLastPoint().lat, file.getLastPoint().lon, settings.getLastKnownMapZoom());
getMyApplication().getSelectedGpxHelper().setGpxFileToDisplay(file);
MapActivity.launchMapActivityMoveToTop(getActivity());
}
} }

View file

@ -10,6 +10,7 @@ import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick; import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
import net.osmand.plus.NavigationService; import net.osmand.plus.NavigationService;
import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmAndTaskManager;
import net.osmand.plus.OsmAndTaskManager.OsmAndTaskRunnable; import net.osmand.plus.OsmAndTaskManager.OsmAndTaskRunnable;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
@ -256,29 +257,11 @@ public class OsmandMonitoringPlugin extends OsmandPlugin implements MonitoringIn
int which = holder[0]; int which = holder[0];
int item = items.get(which); int item = items.get(which);
if(item == R.string.save_current_track){ if(item == R.string.save_current_track){
app.getTaskManager().runInBackground(new OsmAndTaskRunnable<Void, Void, Void>() { saveCurrentTrack();
@Override
protected Void doInBackground(Void... params) {
isSaving = true;
try {
SavingTrackHelper helper = app.getSavingTrackHelper();
helper.saveDataToGpx(app.getAppCustomization().getTracksDir());
helper.close();
} finally {
isSaving = false;
}
return null;
}
}, (Void) null);
} else if(item == R.string.gpx_monitoring_start) { } else if(item == R.string.gpx_monitoring_start) {
startGPXMonitoring(map); startGPXMonitoring(map);
} else if(item == R.string.gpx_monitoring_stop) { } else if(item == R.string.gpx_monitoring_stop) {
settings.SAVE_GLOBAL_TRACK_TO_GPX.set(false); stopRecording();
if (app.getNavigationService() != null) {
app.getNavigationService().stopIfNeeded(app, NavigationService.USED_BY_GPX);
}
} else if(item == R.string.gpx_start_new_segment) { } else if(item == R.string.gpx_start_new_segment) {
app.getSavingTrackHelper().startNewSegment(); app.getSavingTrackHelper().startNewSegment();
} else if(item == R.string.live_monitoring_stop) { } else if(item == R.string.live_monitoring_stop) {
@ -313,6 +296,32 @@ public class OsmandMonitoringPlugin extends OsmandPlugin implements MonitoringIn
} }
} }
public void saveCurrentTrack() {
app.getTaskManager().runInBackground(new OsmAndTaskRunnable<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
isSaving = true;
try {
SavingTrackHelper helper = app.getSavingTrackHelper();
helper.saveDataToGpx(app.getAppCustomization().getTracksDir());
helper.close();
} finally {
isSaving = false;
}
return null;
}
}, (Void) null);
}
public void stopRecording(){
settings.SAVE_GLOBAL_TRACK_TO_GPX.set(false);
if (app.getNavigationService() != null) {
app.getNavigationService().stopIfNeeded(app, NavigationService.USED_BY_GPX);
}
}
private void startGPXMonitoring(MapActivity map) { private void startGPXMonitoring(MapActivity map) {
app.getSavingTrackHelper().startNewSegment(); app.getSavingTrackHelper().startNewSegment();
final ValueHolder<Integer> vs = new ValueHolder<Integer>(); final ValueHolder<Integer> vs = new ValueHolder<Integer>();