diff --git a/OsmAnd/res/layout/audio_video_notes_all.xml b/OsmAnd/res/layout/audio_video_notes_all.xml
index e244ce646b..753e3c1506 100644
--- a/OsmAnd/res/layout/audio_video_notes_all.xml
+++ b/OsmAnd/res/layout/audio_video_notes_all.xml
@@ -5,11 +5,4 @@
android:id="@+id/main_scroll"
android:background="@color/dashboard_background" >
-
-
\ No newline at end of file
diff --git a/OsmAnd/res/layout/dash_note_item.xml b/OsmAnd/res/layout/dash_note_item.xml
index f889db83f8..9fb7872574 100644
--- a/OsmAnd/res/layout/dash_note_item.xml
+++ b/OsmAnd/res/layout/dash_note_item.xml
@@ -6,6 +6,7 @@
android:background="@drawable/dashboard_button"
android:layout_height="@dimen/dashListItemHeight">
items;
+ NotesAdapter listAdapter;
@Override
- protected void onResume() {
- super.onResume();
- setContentView(R.layout.audio_video_notes_all);
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.editing_poi_filter);
+
+ plugin = OsmandPlugin.getEnabledPlugin(AudioVideoNotesPlugin.class);
ColorDrawable color = new ColorDrawable(getResources().getColor(R.color.actionbar_color));
ActionBar actionBar = getSupportActionBar();
@@ -25,6 +48,52 @@ public class DashAudioVideoNotesActivity extends SherlockFragmentActivity {
actionBar.setIcon(android.R.color.transparent);
actionBar.setHomeButtonEnabled(true);
actionBar.setDisplayHomeAsUpEnabled(true);
+ getListView().setBackgroundColor(getResources().getColor(R.color.dashboard_background));
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ items = new ArrayList(plugin.getAllRecordings());
+ listAdapter = new NotesAdapter(items);
+ setListAdapter(listAdapter);
+ }
+
+ private void showContextMenu(final AudioVideoNotesPlugin.Recording recording){
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ final ContextMenuAdapter adapter = new ContextMenuAdapter(this);
+ ContextMenuAdapter.OnContextMenuClick listener = new ContextMenuAdapter.OnContextMenuClick() {
+ @Override
+ public boolean onContextMenuClick(final ArrayAdapter> adapter, int resId, int pos, boolean isChecked) {
+ if (resId == R.string.local_index_mi_delete) {
+ AlertDialog.Builder confirm = new AlertDialog.Builder(DashAudioVideoNotesActivity.this);
+ confirm.setPositiveButton(R.string.default_buttons_yes, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ plugin.deleteRecording(recording);
+ items.remove(recording);
+ listAdapter.notifyDataSetChanged();
+ }
+ });
+ confirm.setNegativeButton(R.string.default_buttons_no, null);
+ confirm.setMessage(getString(R.string.delete_confirmation_msg, recording.file.getName()));
+ confirm.show();
+ }
+ return true;
+ }
+ };
+ adapter.item(R.string.local_index_mi_delete).listen(listener).position(0).reg();
+
+ builder.setItems(adapter.getItemNames(), new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ ContextMenuAdapter.OnContextMenuClick clk = adapter.getClickAdapter(which);
+ if (clk != null){
+ clk.onContextMenuClick(null, adapter.getElementId(which), which, false);
+ }
+ }
+ });
+ builder.show();
}
@Override
@@ -36,4 +105,32 @@ public class DashAudioVideoNotesActivity extends SherlockFragmentActivity {
return super.onOptionsItemSelected(item);
}
}
+
+
+
+ class NotesAdapter extends ArrayAdapter {
+ NotesAdapter(List recordingList) {
+ super(DashAudioVideoNotesActivity.this, R.layout.dash_note_item, recordingList);
+ }
+
+ @Override
+ public View getView(final int position, View convertView, ViewGroup parent) {
+ LayoutInflater inflater = getLayoutInflater();
+ View row = convertView;
+ if (row == null){
+ row = inflater.inflate(R.layout.dash_note_item, parent, false);
+ row.findViewById(R.id.divider).setVisibility(View.GONE);
+ }
+ final AudioVideoNotesPlugin.Recording recording = getItem(position);
+ DashAudioVideoNotesFragment.getNoteView(recording, row, DashAudioVideoNotesActivity.this, plugin);
+ row.setOnLongClickListener(new View.OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View v) {
+ showContextMenu(recording);
+ return true;
+ }
+ });
+ return row;
+ }
+ }
}
diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashAudioVideoNotesFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashAudioVideoNotesFragment.java
index 9903bb7341..b9a397ef6d 100644
--- a/OsmAnd/src/net/osmand/plus/dashboard/DashAudioVideoNotesFragment.java
+++ b/OsmAnd/src/net/osmand/plus/dashboard/DashAudioVideoNotesFragment.java
@@ -1,6 +1,7 @@
package net.osmand.plus.dashboard;
import android.app.Activity;
+import android.content.Context;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
@@ -28,32 +29,25 @@ import java.util.List;
*/
public class DashAudioVideoNotesFragment extends DashBaseFragment {
AudioVideoNotesPlugin plugin;
- boolean allNotes;
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
plugin = OsmandPlugin.getEnabledPlugin(AudioVideoNotesPlugin.class);
View view = getActivity().getLayoutInflater().inflate(R.layout.dash_audio_video_notes_plugin, container, false);
- allNotes = getActivity() instanceof DashAudioVideoNotesActivity;
- if (allNotes) {
- view.findViewById(R.id.header_layout).setVisibility(View.GONE);
- } else {
- Typeface typeface = FontCache.getRobotoMedium(getActivity());
- ((TextView) view.findViewById(R.id.notes_text)).setTypeface(typeface);
- ((Button) view.findViewById(R.id.show_all)).setTypeface(typeface);
-
- (view.findViewById(R.id.show_all)).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- Activity activity = getActivity();
- final Intent favorites = new Intent(activity, DashAudioVideoNotesActivity.class);
- favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
- activity.startActivity(favorites);
- }
- });
- }
+ Typeface typeface = FontCache.getRobotoMedium(getActivity());
+ ((TextView) view.findViewById(R.id.notes_text)).setTypeface(typeface);
+ ((Button) view.findViewById(R.id.show_all)).setTypeface(typeface);
+ (view.findViewById(R.id.show_all)).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ Activity activity = getActivity();
+ final Intent favorites = new Intent(activity, DashAudioVideoNotesActivity.class);
+ favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
+ activity.startActivity(favorites);
+ }
+ });
return view;
}
@@ -92,7 +86,7 @@ public class DashAudioVideoNotesFragment extends DashBaseFragment {
LinearLayout notesLayout = (LinearLayout) mainView.findViewById(R.id.notes);
notesLayout.removeAllViews();
- if (notes.size() > 3 && !allNotes){
+ if (notes.size() > 3){
while (notes.size() != 3){
notes.remove(3);
}
@@ -102,23 +96,7 @@ public class DashAudioVideoNotesFragment extends DashBaseFragment {
LayoutInflater inflater = getActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.dash_note_item, null, false);
- if (recording.name != null){
- ((TextView) view.findViewById(R.id.name)).setText(recording.name);
- ((TextView) view.findViewById(R.id.descr)).setText(recording.getDescription(getActivity()));
- } else {
- ((TextView) view.findViewById(R.id.name)).setText(recording.getDescription(getActivity()));
- view.findViewById(R.id.descr).setVisibility(View.GONE);
- }
-
- ImageView icon = (ImageView) view.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);
- }
-
+ getNoteView(recording, view, getActivity(), plugin);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -128,19 +106,35 @@ public class DashAudioVideoNotesFragment extends DashBaseFragment {
MapActivity.launchMapActivityMoveToTop(getActivity());
}
});
- view.findViewById(R.id.play).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- plugin.playRecording(getActivity(), recording);
- }
- });
-
- //int height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 50, getResources().getDisplayMetrics());
-
- //LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, height);
- //view.setLayoutParams(lp);
notesLayout.addView(view);
}
}
+ 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);
+ ((TextView) view.findViewById(R.id.descr)).setText(recording.getDescription(ctx));
+ } else {
+ ((TextView) view.findViewById(R.id.name)).setText(recording.getDescription(ctx));
+ view.findViewById(R.id.descr).setVisibility(View.GONE);
+ }
+
+ ImageView icon = (ImageView) view.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);
+ }
+
+ view.findViewById(R.id.play).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ plugin.playRecording(ctx, recording);
+ }
+ });
+ }
+
}