commit
31339453be
13 changed files with 247 additions and 56 deletions
|
@ -21,8 +21,8 @@
|
|||
|
||||
<ImageView
|
||||
android:id="@+id/favourite_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_width="@dimen/favorite_icon_size"
|
||||
android:layout_height="@dimen/favorite_icon_size"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginRight="@dimen/favorites_icon_right_margin"/>
|
||||
|
||||
|
|
|
@ -15,7 +15,8 @@
|
|||
android:focusable="false"
|
||||
android:visibility="gone"
|
||||
android:layout_marginRight="@dimen/local_index_check_right_margin"
|
||||
android:layout_gravity="center_vertical"/>
|
||||
android:layout_marginTop="@dimen/favorites_icon_top_margin"
|
||||
/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/icon"
|
||||
|
@ -23,8 +24,8 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="@dimen/favorites_icon_right_margin"
|
||||
android:focusable="false"
|
||||
android:layout_gravity="center_vertical"/>
|
||||
android:layout_marginTop="@dimen/favorites_icon_top_margin"
|
||||
android:focusable="false"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
|
@ -69,7 +70,6 @@
|
|||
android:layout_width="@dimen/list_item_height"
|
||||
android:layout_height="@dimen/list_item_height"
|
||||
android:background="?attr/options_button_background"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:focusable="false"
|
||||
android:src="?attr/list_settings_icon"/>
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:textSize="@dimen/download_descr_text_size"
|
||||
android:maxLines="25"
|
||||
tools:text="@string/app_mode_aircraft"/>
|
||||
|
||||
|
|
30
OsmAnd/res/layout/note_edit_dialog.xml
Normal file
30
OsmAnd/res/layout/note_edit_dialog.xml
Normal file
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="@dimen/dialog_content_bottom_margin"
|
||||
android:paddingLeft="@dimen/dialog_content_margin"
|
||||
android:paddingRight="@dimen/dialog_content_margin"
|
||||
android:paddingTop="@dimen/dialog_content_bottom_margin">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dialog_elements_vertical_margin"
|
||||
android:text="@string/favourites_edit_dialog_name"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/name"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:selectAllOnFocus="true"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -23,6 +23,7 @@
|
|||
android:id="@+id/header"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/list_header_padding"
|
||||
android:text="@string/download_tab_updates"/>
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
<dimen name="dialog_content_margin">24dp</dimen>
|
||||
<dimen name="dialog_content_bottom_margin">16dp</dimen>
|
||||
<dimen name="local_size_height">34dp</dimen>
|
||||
<dimen name="favorite_icon_size">24dp</dimen>
|
||||
|
||||
<!-- TextSizes -->
|
||||
<dimen name="list_header_text_size">14sp</dimen>
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
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="share_note">Share note</string>
|
||||
<string name="rename_recording">Rename recording</string>
|
||||
<string name="watch">Watch</string>
|
||||
<string name="notes">Notes</string>
|
||||
<string name="online_map">Online map</string>
|
||||
|
@ -1788,7 +1790,7 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A
|
|||
<string name="fav_saved_sucessfully">Favorites successfully saved to {0}</string>
|
||||
<string name="no_fav_to_save">No favorite points to save</string>
|
||||
<string name="import_fav">Import</string>
|
||||
<string name="export_fav">Export</string>
|
||||
<string name="export">Export</string>
|
||||
<string name="share_fav">Share</string>
|
||||
<string name="share_fav_subject">Favourites shared via OsmAnd</string>
|
||||
<string name="error_occurred_loading_gpx">Error occurred while loading GPX</string>
|
||||
|
|
|
@ -16,6 +16,7 @@ import android.os.Handler;
|
|||
import android.support.v4.view.MenuItemCompat;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.support.v7.view.ActionMode;
|
||||
import android.support.v7.widget.PopupMenu;
|
||||
import android.support.v7.widget.SearchView;
|
||||
import android.view.*;
|
||||
import net.osmand.IndexConstants;
|
||||
|
@ -30,6 +31,7 @@ import net.osmand.plus.OsmandApplication;
|
|||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.dialogs.DirectionsDialogs;
|
||||
import net.osmand.plus.helpers.GpxUiHelper;
|
||||
import net.osmand.plus.helpers.ScreenOrientationHelper;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
@ -54,6 +56,8 @@ import android.widget.ExpandableListView;
|
|||
import android.widget.ExpandableListView.ExpandableListContextMenuInfo;
|
||||
import android.widget.Filter;
|
||||
import android.widget.Filterable;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
@ -62,12 +66,11 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
|||
|
||||
|
||||
public static final int SEARCH_ID = -1;
|
||||
public static final int ACTION_ID = 0;
|
||||
protected static final int DELETE_ACTION_ID = 1;
|
||||
// public static final int ACTION_ID = 0;
|
||||
// protected static final int DELETE_ACTION_ID = 1;
|
||||
private boolean selectionMode = false;
|
||||
private List<GpxInfo> selectedItems = new ArrayList<GpxInfo>();
|
||||
private List<GpxInfo> selectedItems = new ArrayList<>();
|
||||
private ActionMode actionMode;
|
||||
private SearchView searchView;
|
||||
private LoadGpxTask asyncLoader;
|
||||
private GpxIndexesAdapter listAdapter;
|
||||
MessageFormat formatMb = new MessageFormat("{0, number,##.#} MB", Locale.US);
|
||||
|
@ -99,17 +102,6 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
|||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View vs = super.onCreateView(inflater, container, savedInstanceState);
|
||||
getExpandableListView().setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() {
|
||||
@Override
|
||||
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
|
||||
long packedPos = ((ExpandableListContextMenuInfo) menuInfo).packedPosition;
|
||||
int group = ExpandableListView.getPackedPositionGroup(packedPos);
|
||||
int child = ExpandableListView.getPackedPositionChild(packedPos);
|
||||
if (child >= 0 && group >= 0) {
|
||||
showContextMenu(listAdapter.getChild(group, child));
|
||||
}
|
||||
}
|
||||
});
|
||||
return vs;
|
||||
}
|
||||
|
||||
|
@ -137,9 +129,9 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
|||
MenuItem mi = createMenuItem(menu, SEARCH_ID, R.string.search_poi_filter, R.drawable.ic_action_search_dark,
|
||||
R.drawable.ic_action_search_dark, MenuItemCompat.SHOW_AS_ACTION_ALWAYS
|
||||
| MenuItemCompat.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
|
||||
searchView = new SearchView(getActivity());
|
||||
SearchView searchView = new SearchView(getActivity());
|
||||
FavoritesActivity.updateSearchView(getActivity(), searchView);
|
||||
MenuItemCompat.setActionView(mi,searchView);
|
||||
MenuItemCompat.setActionView(mi, searchView);
|
||||
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
||||
|
||||
@Override
|
||||
|
@ -464,21 +456,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
|||
sendIntent.setType("application/gpx+xml");
|
||||
startActivity(sendIntent);
|
||||
} else if (resId == R.string.show_gpx_route) {
|
||||
info.updateGpxInfo(getMyApplication());
|
||||
boolean e = true;
|
||||
if (info != null && info.gpx != null) {
|
||||
WptPt loc = info.gpx.findPointToShow();
|
||||
OsmandSettings settings = getMyApplication().getSettings();
|
||||
if (loc != null) {
|
||||
settings.setMapLocationToShow(loc.lat, loc.lon, settings.getLastKnownMapZoom());
|
||||
e = false;
|
||||
getMyApplication().getSelectedGpxHelper().setGpxFileToDisplay(info.gpx);
|
||||
MapActivity.launchMapActivityMoveToTop(getActivity());
|
||||
}
|
||||
}
|
||||
if (e) {
|
||||
AccessibleToast.makeText(getActivity(), R.string.gpx_file_is_empty, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
showGpxOnMap(info);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -506,6 +484,24 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
|||
OsmandPlugin.onContextMenuActivity(getActivity(), this, info, adapter);
|
||||
}
|
||||
|
||||
private void showGpxOnMap(GpxInfo info) {
|
||||
info.updateGpxInfo(getMyApplication());
|
||||
boolean e = true;
|
||||
if (info != null && info.gpx != null) {
|
||||
WptPt loc = info.gpx.findPointToShow();
|
||||
OsmandSettings settings = getMyApplication().getSettings();
|
||||
if (loc != null) {
|
||||
settings.setMapLocationToShow(loc.lat, loc.lon, settings.getLastKnownMapZoom());
|
||||
e = false;
|
||||
getMyApplication().getSelectedGpxHelper().setGpxFileToDisplay(info.gpx);
|
||||
MapActivity.launchMapActivityMoveToTop(getActivity());
|
||||
}
|
||||
}
|
||||
if (e) {
|
||||
AccessibleToast.makeText(getActivity(), R.string.gpx_file_is_empty, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
||||
private void showContextMenu(final GpxInfo info) {
|
||||
Builder builder = new AlertDialog.Builder(getActivity());
|
||||
final ContextMenuAdapter adapter = new ContextMenuAdapter(getActivity());
|
||||
|
@ -577,6 +573,9 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
|||
if(getActivity() != null) {
|
||||
((ActionBarActivity)getActivity()).setSupportProgressBarIndeterminateVisibility(false);
|
||||
}
|
||||
if (listAdapter.getGroupCount() > 0){
|
||||
getExpandableListView().expandGroup(0);
|
||||
}
|
||||
}
|
||||
|
||||
private File[] listFilesSorted(File dir) {
|
||||
|
@ -712,7 +711,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
|||
}
|
||||
|
||||
@Override
|
||||
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
|
||||
public View getChildView(final int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
|
||||
View v = convertView;
|
||||
final GpxInfo child = getChild(groupPosition, childPosition);
|
||||
if (v == null) {
|
||||
|
@ -750,8 +749,16 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
|||
} else {
|
||||
descr.setVisibility(View.GONE);
|
||||
}
|
||||
ImageButton options = (ImageButton) v.findViewById(R.id.options);
|
||||
options.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
openPopUpMenu(v, child);
|
||||
}
|
||||
});
|
||||
final CheckBox checkbox = (CheckBox) v.findViewById(R.id.check_local_index);
|
||||
checkbox.setVisibility(selectionMode ? View.VISIBLE : View.GONE);
|
||||
ImageView icon = (ImageView) v.findViewById(R.id.icon);
|
||||
if (selectionMode) {
|
||||
checkbox.setChecked(selectedItems.contains(child));
|
||||
checkbox.setOnClickListener(new View.OnClickListener() {
|
||||
|
@ -767,9 +774,19 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
|||
updateSelectionMode(actionMode);
|
||||
}
|
||||
});
|
||||
icon.setVisibility(View.GONE);
|
||||
options.setVisibility(View.GONE);
|
||||
} else {
|
||||
icon.setVisibility(View.VISIBLE);
|
||||
options.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
|
||||
v.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
onChildClick(null, v, groupPosition, childPosition, 0);
|
||||
}
|
||||
});
|
||||
return v;
|
||||
}
|
||||
|
||||
|
@ -861,6 +878,63 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
|||
}
|
||||
}
|
||||
|
||||
private void openPopUpMenu(View v, final GpxInfo gpxInfo) {
|
||||
boolean light = getMyApplication().getSettings().isLightContent();
|
||||
final PopupMenu optionsMenu = new PopupMenu(getActivity(), v);
|
||||
DirectionsDialogs.setupPopUpMenuIcon(optionsMenu);
|
||||
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);
|
||||
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
showGpxOnMap(gpxInfo);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
item = optionsMenu.getMenu().add(R.string.local_index_mi_rename)
|
||||
.setIcon(light ? R.drawable.ic_action_edit_light : R.drawable.ic_action_edit_dark);
|
||||
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
item = optionsMenu.getMenu().add(R.string.export)
|
||||
.setIcon(light ? R.drawable.ic_action_gup_light : R.drawable.ic_action_gup_dark);
|
||||
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
item = optionsMenu.getMenu().add(R.string.edit_filter_delete_menu_item)
|
||||
.setIcon(light ? R.drawable.ic_action_delete_light : R.drawable.ic_action_delete_dark);
|
||||
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
builder.setMessage(R.string.recording_delete_confirm);
|
||||
builder.setPositiveButton(R.string.default_buttons_yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
operationTask = new DeleteGpxTask();
|
||||
operationTask.execute(gpxInfo);
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(R.string.default_buttons_cancel, null);
|
||||
builder.show();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
optionsMenu.show();
|
||||
|
||||
}
|
||||
|
||||
public class LoadLocalIndexDescriptionTask extends AsyncTask<GpxInfo, GpxInfo, GpxInfo[]> {
|
||||
|
||||
@Override
|
||||
|
@ -1185,8 +1259,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
|||
description = gpx.warning;
|
||||
} else {
|
||||
// 'Long-press for options' message
|
||||
description = GpxUiHelper.getDescription(app, gpx, file, true) +
|
||||
app.getString(R.string.local_index_gpx_info_show);
|
||||
description = GpxUiHelper.getDescription(app, gpx, file, true);
|
||||
}
|
||||
htmlDescription = null;
|
||||
getHtmlDescription();
|
||||
|
|
|
@ -20,6 +20,7 @@ import android.view.MenuItem;
|
|||
import net.osmand.plus.GpxSelectionHelper;
|
||||
import net.osmand.plus.OsmAndLocationProvider;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import android.os.Bundle;
|
||||
|
@ -29,6 +30,8 @@ import android.view.View;
|
|||
import android.widget.ImageView;
|
||||
import android.widget.TabHost.TabSpec;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
|
||||
import net.osmand.plus.audionotes.NotesFragment;
|
||||
import net.osmand.plus.views.controls.PagerSlidingTabStrip;
|
||||
|
||||
|
@ -79,8 +82,11 @@ public class FavoritesActivity extends TabActivity {
|
|||
List<TabItem> mTabs = new ArrayList<TabItem>();
|
||||
mTabs.add(getTabIndicator(R.string.my_favorites, FavoritesTreeFragment.class));
|
||||
mTabs.add(getTabIndicator(R.string.my_tracks, AvailableGPXFragment.class));
|
||||
|
||||
mTabs.add(getTabIndicator(R.string.notes, NotesFragment.class));
|
||||
AudioVideoNotesPlugin audioVideoNotesPlugin = OsmandPlugin.getEnabledPlugin(AudioVideoNotesPlugin.class);
|
||||
if (audioVideoNotesPlugin != null && audioVideoNotesPlugin.isActive()
|
||||
&& audioVideoNotesPlugin.getAllRecordings().size() > 0){
|
||||
mTabs.add(getTabIndicator(R.string.notes, NotesFragment.class));
|
||||
}
|
||||
mTabs.add(getTabIndicator(R.string.selected_track, SelectedGPXFragment.class));
|
||||
|
||||
setViewPagerAdapter(mViewPager, mTabs);
|
||||
|
|
|
@ -169,10 +169,10 @@ public class AudioNotesLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
@Override
|
||||
public String getObjectName(Object o) {
|
||||
if(o instanceof Recording){
|
||||
if(((Recording)o).name == null) {
|
||||
if(((Recording)o).getName() == null) {
|
||||
return view.getResources().getString(R.string.recording_default_name);
|
||||
}
|
||||
return ((Recording)o).name; //$NON-NLS-1$
|
||||
return ((Recording)o).getName(); //$NON-NLS-1$
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -137,8 +137,8 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
|||
}
|
||||
|
||||
public File file;
|
||||
public String name;
|
||||
|
||||
private String name;
|
||||
private double lat;
|
||||
private double lon;
|
||||
private long duration = -1;
|
||||
|
@ -170,6 +170,14 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
|||
}
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public boolean isPhoto() {
|
||||
return file.getName().endsWith(IMG_EXTENSION);
|
||||
}
|
||||
|
@ -301,6 +309,9 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
|||
return additional;
|
||||
}
|
||||
|
||||
public void setDescription() {
|
||||
//TODO implement setting description
|
||||
}
|
||||
}
|
||||
|
||||
private static void initializeRemoteControlRegistrationMethods() {
|
||||
|
|
|
@ -96,7 +96,7 @@ public class DashAudioVideoNotesFragment extends DashBaseFragment {
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
getMyApplication().getSettings().setMapLocationToShow(recording.getLatitude(), recording.getLongitude(), 15, null,
|
||||
recording.name != null ? recording.name : recording.getDescription(getActivity()),
|
||||
recording.getName() != null ? recording.getName() : recording.getDescription(getActivity()),
|
||||
recording); //$NON-NLS-1$
|
||||
MapActivity.launchMapActivityMoveToTop(getActivity());
|
||||
}
|
||||
|
@ -107,8 +107,8 @@ public class DashAudioVideoNotesFragment extends DashBaseFragment {
|
|||
|
||||
public static void getNoteView(final AudioVideoNotesPlugin.Recording recording, View view,
|
||||
final Context ctx, final AudioVideoNotesPlugin plugin) {
|
||||
if (recording.name != null){
|
||||
((TextView) view.findViewById(R.id.name)).setText(recording.name);
|
||||
if (recording.getName() != null){
|
||||
((TextView) view.findViewById(R.id.name)).setText(recording.getName());
|
||||
((TextView) view.findViewById(R.id.descr)).setText(recording.getDescription(ctx));
|
||||
} else {
|
||||
((TextView) view.findViewById(R.id.name)).setText(recording.getDescription(ctx));
|
||||
|
|
|
@ -1,19 +1,29 @@
|
|||
package net.osmand.plus.audionotes;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.widget.PopupMenu;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.FavoritesActivity;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.audionotes.AudioVideoNotesPlugin.Recording;
|
||||
import net.osmand.plus.dialogs.DirectionsDialogs;
|
||||
import android.support.v4.app.ListFragment;
|
||||
|
@ -43,11 +53,16 @@ public class NotesFragment extends ListFragment {
|
|||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
items = new ArrayList<Recording>(plugin.getAllRecordings());
|
||||
items = new ArrayList<>(plugin.getAllRecordings());
|
||||
listAdapter = new NotesAdapter(items);
|
||||
getListView().setAdapter(listAdapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
((FavoritesActivity) getActivity()).getClearToolbar(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
|
@ -60,7 +75,7 @@ public class NotesFragment extends ListFragment {
|
|||
|
||||
class NotesAdapter extends ArrayAdapter<AudioVideoNotesPlugin.Recording> {
|
||||
NotesAdapter(List<AudioVideoNotesPlugin.Recording> recordingList) {
|
||||
super(getActivity(), R.layout.dash_audio_video_notes_item, recordingList);
|
||||
super(getActivity(), R.layout.note, recordingList);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -72,9 +87,10 @@ public class NotesFragment extends ListFragment {
|
|||
}
|
||||
|
||||
final AudioVideoNotesPlugin.Recording recording = getItem(position);
|
||||
if (recording.name != null){
|
||||
((TextView) row.findViewById(R.id.name)).setText(recording.name);
|
||||
if (recording.getName() != null){
|
||||
((TextView) row.findViewById(R.id.name)).setText(recording.getName());
|
||||
((TextView) row.findViewById(R.id.descr)).setText(recording.getDescription(getActivity()));
|
||||
row.findViewById(R.id.descr).setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
((TextView) row.findViewById(R.id.name)).setText(recording.getDescription(getActivity()));
|
||||
row.findViewById(R.id.descr).setVisibility(View.GONE);
|
||||
|
@ -126,6 +142,9 @@ public class NotesFragment extends ListFragment {
|
|||
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
getMyApplication().getSettings().setMapLocationToShow(recording.getLatitude(), recording.getLongitude(), 15, null, recording.getName(),
|
||||
recording); //$NON-NLS-1$
|
||||
MapActivity.launchMapActivityMoveToTop(getActivity());
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
@ -135,6 +154,21 @@ public class NotesFragment extends ListFragment {
|
|||
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
|
||||
if (recording.isPhoto()) {
|
||||
Uri screenshotUri = Uri.parse(recording.file.getAbsolutePath());
|
||||
sharingIntent.setType("image/*");
|
||||
sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
|
||||
} else if (recording.isAudio()) {
|
||||
Uri audioUri = Uri.parse(recording.file.getAbsolutePath());
|
||||
sharingIntent.setType("audio/*");
|
||||
sharingIntent.putExtra(Intent.EXTRA_STREAM, audioUri);
|
||||
} else if (recording.isVideo()) {
|
||||
Uri videoUri = Uri.parse(recording.file.getAbsolutePath());
|
||||
sharingIntent.setType("video/*");
|
||||
sharingIntent.putExtra(Intent.EXTRA_STREAM, videoUri);
|
||||
}
|
||||
startActivity(Intent.createChooser(sharingIntent, getString(R.string.share_note)));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
@ -144,6 +178,7 @@ public class NotesFragment extends ListFragment {
|
|||
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
editNote(recording);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
@ -153,11 +188,42 @@ public class NotesFragment extends ListFragment {
|
|||
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
plugin.deleteRecording(recording);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
builder.setMessage(R.string.recording_delete_confirm);
|
||||
builder.setPositiveButton(R.string.default_buttons_yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
plugin.deleteRecording(recording);
|
||||
listAdapter.remove(recording);
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(R.string.default_buttons_cancel, null);
|
||||
builder.show();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
optionsMenu.show();
|
||||
}
|
||||
|
||||
private void editNote(final Recording recording) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
builder.setTitle(R.string.rename_recording);
|
||||
final View v = getActivity().getLayoutInflater().inflate(R.layout.note_edit_dialog,
|
||||
getListView(), false);
|
||||
final EditText editText = (EditText) v.findViewById(R.id.name);
|
||||
builder.setView(v);
|
||||
editText.setText(recording.getName());
|
||||
builder.setNegativeButton(R.string.default_buttons_cancel, null);
|
||||
builder.setPositiveButton(R.string.default_buttons_apply, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
recording.setName(editText.getText().toString());
|
||||
recording.setDescription();
|
||||
listAdapter.notifyDataSetInvalidated();
|
||||
}
|
||||
});
|
||||
builder.create().show();
|
||||
editText.requestFocus();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue