mirror of
https://github.com/nextcloud/android.git
synced 2024-11-22 13:15:35 +03:00
FileDetailsFragment now working on tablets
This commit is contained in:
parent
54909e5372
commit
ffc941e440
3 changed files with 40 additions and 21 deletions
|
@ -24,7 +24,7 @@
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/file_list_container"
|
android:id="@+id/file_list_container"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="fill_parent"
|
||||||
android:layout_weight="1" >
|
android:layout_weight="1" >
|
||||||
|
|
||||||
<fragment
|
<fragment
|
||||||
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
<LinearLayout android:id="@+id/file_details_container"
|
<LinearLayout android:id="@+id/file_details_container"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="fill_parent"
|
||||||
android:layout_weight="2" >
|
android:layout_weight="2" >
|
||||||
|
|
||||||
<fragment
|
<fragment
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class FileDetailFragment extends SherlockFragment implements
|
||||||
public static final String FILE = "FILE";
|
public static final String FILE = "FILE";
|
||||||
|
|
||||||
private Intent mIntent;
|
private Intent mIntent;
|
||||||
private View mView;
|
//private View mView;
|
||||||
private DownloadFinishReceiver mDownloadFinishReceiver;
|
private DownloadFinishReceiver mDownloadFinishReceiver;
|
||||||
private OCFile mFile;
|
private OCFile mFile;
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ public class FileDetailFragment extends SherlockFragment implements
|
||||||
* to contain {@link FileDetailFragment#FILE} with an OCFile and also
|
* to contain {@link FileDetailFragment#FILE} with an OCFile and also
|
||||||
* {@link FileDownloader#EXTRA_ACCOUNT} with the account.
|
* {@link FileDownloader#EXTRA_ACCOUNT} with the account.
|
||||||
*
|
*
|
||||||
* @param nonEmptyFragment True, to enable file detail rendering
|
* @param intent Intent with an account and a file in it for rendering
|
||||||
*/
|
*/
|
||||||
public FileDetailFragment(Intent intent) {
|
public FileDetailFragment(Intent intent) {
|
||||||
mLayout = R.layout.file_details_fragment;
|
mLayout = R.layout.file_details_fragment;
|
||||||
|
@ -124,7 +124,7 @@ public class FileDetailFragment extends SherlockFragment implements
|
||||||
setFilesize(mFile.getFileLength());
|
setFilesize(mFile.getFileLength());
|
||||||
|
|
||||||
// set file preview if available and possible
|
// set file preview if available and possible
|
||||||
VideoView videoView = (VideoView) mView
|
VideoView videoView = (VideoView) getView()
|
||||||
.findViewById(R.id.videoView1);
|
.findViewById(R.id.videoView1);
|
||||||
videoView.setVisibility(View.INVISIBLE);
|
videoView.setVisibility(View.INVISIBLE);
|
||||||
if (mFile.getStoragePath() == null) {
|
if (mFile.getStoragePath() == null) {
|
||||||
|
@ -134,7 +134,7 @@ public class FileDetailFragment extends SherlockFragment implements
|
||||||
imageView.setOnClickListener(this);
|
imageView.setOnClickListener(this);
|
||||||
} else {
|
} else {
|
||||||
if (mFile.getMimetype().startsWith("image/")) {
|
if (mFile.getMimetype().startsWith("image/")) {
|
||||||
ImageView imageView = (ImageView) mView
|
ImageView imageView = (ImageView) getView()
|
||||||
.findViewById(R.id.imageView2);
|
.findViewById(R.id.imageView2);
|
||||||
Bitmap bmp = BitmapFactory.decodeFile(mFile.getStoragePath());
|
Bitmap bmp = BitmapFactory.decodeFile(mFile.getStoragePath());
|
||||||
imageView.setImageBitmap(bmp);
|
imageView.setImageBitmap(bmp);
|
||||||
|
@ -151,23 +151,25 @@ public class FileDetailFragment extends SherlockFragment implements
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = null;
|
View view = null;
|
||||||
|
|
||||||
view = inflater.inflate(mLayout, container, false);
|
view = inflater.inflate(mLayout, container, false);
|
||||||
mIntent = getActivity().getIntent();
|
|
||||||
mView = view;
|
|
||||||
|
|
||||||
// make sure we are not using the empty layout
|
|
||||||
if (mEmptyLayout == false) {
|
|
||||||
updateFileDetails();
|
|
||||||
}
|
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View getView() {
|
public void onStart() {
|
||||||
return mView == null ? super.getView() : mView;
|
super.onStart();
|
||||||
};
|
|
||||||
|
// Fill in required information about file displaying
|
||||||
|
if(mIntent == null){
|
||||||
|
mIntent = getActivity().getIntent();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fill in the details if the layout is not empty
|
||||||
|
if(!mEmptyLayout){
|
||||||
|
updateFileDetails();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private void setFilename(String filename) {
|
private void setFilename(String filename) {
|
||||||
TextView tv = (TextView) getView().findViewById(R.id.textView1);
|
TextView tv = (TextView) getView().findViewById(R.id.textView1);
|
||||||
|
|
|
@ -84,6 +84,8 @@ public class FileListFragment extends FragmentListView {
|
||||||
((FileDisplayActivity) getActivity()).pushPath(dirname);
|
((FileDisplayActivity) getActivity()).pushPath(dirname);
|
||||||
|
|
||||||
populateFileList();
|
populateFileList();
|
||||||
|
resetFileFragment();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,11 +109,11 @@ public class FileListFragment extends FragmentListView {
|
||||||
|
|
||||||
if (fd.isEmptyLayout()) {
|
if (fd.isEmptyLayout()) {
|
||||||
// True, if this is the first time a user taps on a file
|
// True, if this is the first time a user taps on a file
|
||||||
fd = new FileDetailFragment(showDetailsIntent);
|
|
||||||
FragmentTransaction transaction = getFragmentManager()
|
FragmentTransaction transaction = getFragmentManager()
|
||||||
.beginTransaction();
|
.beginTransaction();
|
||||||
transaction.replace(R.id.file_details_container, fd,
|
fd = new FileDetailFragment(showDetailsIntent);
|
||||||
"FileDetails");
|
transaction.replace(R.id.fileDetail, fd, "FileDetails");
|
||||||
|
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
|
||||||
transaction.commit();
|
transaction.commit();
|
||||||
} else {
|
} else {
|
||||||
fd.updateFileDetails(showDetailsIntent);
|
fd.updateFileDetails(showDetailsIntent);
|
||||||
|
@ -122,6 +124,20 @@ public class FileListFragment extends FragmentListView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets the FileDetailsFragment on Tablets
|
||||||
|
* so that it always displays "Tab on a file to display it's details"
|
||||||
|
*/
|
||||||
|
private void resetFileFragment() {
|
||||||
|
FileDetailFragment fileDetails = (FileDetailFragment) getFragmentManager().findFragmentByTag("FileDetails");
|
||||||
|
if(fileDetails != null){
|
||||||
|
FragmentTransaction transaction = getFragmentManager().beginTransaction();
|
||||||
|
transaction.remove(fileDetails);
|
||||||
|
transaction.add(R.id.file_details_container, new FileDetailFragment());
|
||||||
|
transaction.commit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2,
|
public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2,
|
||||||
long arg3) {
|
long arg3) {
|
||||||
|
@ -140,6 +156,7 @@ public class FileListFragment extends FragmentListView {
|
||||||
public void onNavigateUp() {
|
public void onNavigateUp() {
|
||||||
mDirNames.pop();
|
mDirNames.pop();
|
||||||
populateFileList();
|
populateFileList();
|
||||||
|
resetFileFragment();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue