[Android] Show file path and delete option in info panel
Geoffrey Métais
git at videolan.org
Tue Jan 6 18:10:42 CET 2015
vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Jan 6 18:09:51 2015 +0100| [5c01695ec990b3974c8b7f8f90c568e6c1e99344] | committer: Geoffrey Métais
Show file path and delete option in info panel
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=5c01695ec990b3974c8b7f8f90c568e6c1e99344
---
vlc-android/res/layout-land/media_info.xml | 28 +++++++++++--
vlc-android/res/layout/media_info.xml | 23 +++++++++--
vlc-android/res/values/colors.xml | 1 +
.../videolan/vlc/gui/video/MediaInfoFragment.java | 41 +++++++++++++++++++-
4 files changed, 85 insertions(+), 8 deletions(-)
diff --git a/vlc-android/res/layout-land/media_info.xml b/vlc-android/res/layout-land/media_info.xml
index 0038f99..4ac6ac9 100644
--- a/vlc-android/res/layout-land/media_info.xml
+++ b/vlc-android/res/layout-land/media_info.xml
@@ -53,18 +53,40 @@
android:visibility="invisible" />
</FrameLayout>
<TextView
+ android:id="@+id/info_path"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="10dp"
+ android:layout_below="@+id/image_container"/>
+ <TextView
android:id="@+id/size_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/file_size"
android:layout_marginRight="5dp"
- android:layout_below="@+id/image_container"/>
+ android:layout_below="@+id/info_path"
+ android:layout_alignBottom="@+id/info_delete"
+ android:layout_alignTop="@+id/info_delete"
+ android:gravity="center_vertical"/>
<TextView
android:id="@+id/size_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_below="@+id/image_container"
- android:layout_toRightOf="@+id/size_title"/>
+ android:layout_below="@+id/info_path"
+ android:layout_toRightOf="@+id/size_title"
+ android:layout_alignBottom="@+id/info_delete"
+ android:layout_alignTop="@+id/info_delete"
+ android:gravity="center_vertical"/>
+ <TextView
+ android:id="@+id/info_delete"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_below="@+id/info_path"
+ android:layout_alignParentRight="true"
+ android:clickable="true"
+ android:text="@string/delete"
+ android:textColor="@color/blue"
+ android:textAllCaps="true"/>
</RelativeLayout>
<ListView
android:id="@id/android:list"
diff --git a/vlc-android/res/layout/media_info.xml b/vlc-android/res/layout/media_info.xml
index a2c60f6..a6e9096 100644
--- a/vlc-android/res/layout/media_info.xml
+++ b/vlc-android/res/layout/media_info.xml
@@ -48,19 +48,36 @@
android:visibility="invisible" />
</FrameLayout>
<TextView
+ android:id="@+id/info_path"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="5dp"
+ android:layout_below="@+id/image_container"/>
+ <TextView
android:id="@+id/size_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/file_size"
- android:layout_marginLeft="30dp"
+ android:layout_marginLeft="10dp"
android:layout_marginRight="5dp"
- android:layout_below="@+id/image_container"/>
+ android:layout_below="@+id/info_path"/>
<TextView
android:id="@+id/size_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_below="@+id/image_container"
+ android:layout_below="@+id/info_path"
android:layout_toRightOf="@+id/size_title"/>
+ <TextView
+ android:id="@+id/info_delete"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_below="@+id/info_path"
+ android:layout_alignParentRight="true"
+ android:layout_marginRight="10dp"
+ android:clickable="true"
+ android:text="@string/delete"
+ android:textColor="@color/blue"
+ android:textAllCaps="true"/>
</RelativeLayout>
<ListView
diff --git a/vlc-android/res/values/colors.xml b/vlc-android/res/values/colors.xml
index 1edc6a8..ecfd554 100644
--- a/vlc-android/res/values/colors.xml
+++ b/vlc-android/res/values/colors.xml
@@ -12,6 +12,7 @@
<color name="font_default">#222222</color>
<color name="font_light">#777777</color>
<color name="orange">#ffbb33</color>
+ <color name="blue">#0000ff</color>
<color name="darkorange">#ff8800</color>
<color name="darkerorange">#ff7200</color>
<color name="black">#000001</color>
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoFragment.java b/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoFragment.java
index 16981e5..a7d0afc 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoFragment.java
@@ -25,6 +25,7 @@ import java.nio.ByteBuffer;
import org.videolan.libvlc.LibVLC;
import org.videolan.libvlc.LibVlcException;
+import org.videolan.libvlc.LibVlcUtil;
import org.videolan.libvlc.Media;
import org.videolan.libvlc.TrackInfo;
import org.videolan.vlc.MediaLibrary;
@@ -32,6 +33,7 @@ import org.videolan.vlc.R;
import org.videolan.vlc.gui.MainActivity;
import org.videolan.vlc.util.BitmapUtil;
import org.videolan.vlc.util.Strings;
+import org.videolan.vlc.util.Util;
import org.videolan.vlc.util.VLCInstance;
import org.videolan.vlc.util.WeakHandler;
@@ -62,12 +64,16 @@ public class MediaInfoFragment extends ListFragment {
private Bitmap mImage;
private TextView mLengthView;
private TextView mSizeView;
+ private TextView mPathView;
private ImageButton mPlayButton;
+ private TextView mDelete;
private TrackInfo[] mTracks;
private MediaInfoAdapter mAdapter;
private final static int NEW_IMAGE = 0;
private final static int NEW_TEXT = 1;
private final static int NEW_SIZE = 2;
+ private final static int HIDE_DELETE = 3;
+ private final static int EXIT = 4;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
@@ -76,8 +82,13 @@ public class MediaInfoFragment extends ListFragment {
mLengthView = (TextView) v.findViewById(R.id.length);
mSizeView = (TextView) v.findViewById(R.id.size_value);
+ mPathView = (TextView) v.findViewById(R.id.info_path);
mPlayButton = (ImageButton) v.findViewById(R.id.play);
+ mDelete = (TextView) v.findViewById(R.id.info_delete);
+ if (!LibVlcUtil.isICSOrLater())
+ mDelete.setText(getString(R.string.delete).toUpperCase());
+ mPathView.setText(Uri.decode(mItem.getLocation().substring(7)));
mPlayButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
@@ -85,6 +96,22 @@ public class MediaInfoFragment extends ListFragment {
}
});
+ mDelete.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (mItem != null) {
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ boolean deleted = Util.deleteFile(getActivity(), mItem.getLocation());
+ if (deleted) {
+ mHandler.obtainMessage(EXIT).sendToTarget();
+ }
+ }
+ }).start();
+ }
+ }
+ });
mAdapter = new MediaInfoAdapter(getActivity());
setListAdapter(mAdapter);
@@ -104,7 +131,7 @@ public class MediaInfoFragment extends ListFragment {
mLengthView.setText(Strings.millisToString(mItem.getLength()));
new Thread(mLoadImage).start();
- new Thread(mLoadSize).start();
+ new Thread(mCheckFile).start();
}
public void setMediaLocation(String MRL) {
@@ -113,10 +140,12 @@ public class MediaInfoFragment extends ListFragment {
mItem = MediaLibrary.getInstance().getMediaItem(MRL);
}
- Runnable mLoadSize = new Runnable() {
+ Runnable mCheckFile = new Runnable() {
@Override
public void run() {
File itemFile = new File(Uri.decode(mItem.getLocation().substring(5)));
+ if (!itemFile.canWrite())
+ mHandler.obtainMessage(HIDE_DELETE).sendToTarget();
long length = itemFile.length();
mHandler.obtainMessage(NEW_SIZE, Long.valueOf(length)).sendToTarget();
}
@@ -213,6 +242,14 @@ public class MediaInfoFragment extends ListFragment {
case NEW_SIZE:
fragment.updateSize((Long) msg.obj);
break;
+ case HIDE_DELETE:
+ fragment.mDelete.setClickable(false);
+ fragment.mDelete.setVisibility(View.GONE);
+ break;
+ case EXIT:
+ ((MainActivity) fragment.getActivity()).popSecondaryFragment();
+ MediaLibrary.getInstance().loadMediaItems(fragment.getActivity(), true);
+ break;
}
};
More information about the Android
mailing list