Added renaming for audio video notes
This commit is contained in:
parent
c684b01f2b
commit
80be3b8b1c
6 changed files with 73 additions and 120 deletions
|
@ -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>
|
|
|
@ -64,4 +64,13 @@
|
||||||
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>
|
|
@ -9,6 +9,7 @@
|
||||||
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="currently_recording_track">Currently recording track</string>
|
||||||
<string name="back_to_map">Back to map</string>
|
<string name="back_to_map">Back to map</string>
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
|
@ -94,15 +94,22 @@ 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.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 +120,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 +142,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);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue