Commit 5c01695e authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

Show file path and delete option in info panel

parent e0564a16
......@@ -52,19 +52,41 @@
android:textColor="@color/white"
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"
......
......@@ -47,20 +47,37 @@
android:textColor="@color/white"
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
......
......@@ -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>
......
......@@ -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;
}
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment