|
@@ -34,12 +34,8 @@ import android.view.MenuItem;
|
|
|
import android.view.View;
|
|
|
import android.view.View.OnClickListener;
|
|
|
import android.view.ViewGroup;
|
|
|
-import android.widget.ImageButton;
|
|
|
-import android.widget.ImageView;
|
|
|
-import android.widget.LinearLayout;
|
|
|
import android.widget.PopupMenu;
|
|
|
import android.widget.ProgressBar;
|
|
|
-import android.widget.TextView;
|
|
|
|
|
|
import com.google.android.material.tabs.TabLayout;
|
|
|
import com.nextcloud.client.account.User;
|
|
@@ -50,6 +46,7 @@ import com.nextcloud.client.network.ConnectivityService;
|
|
|
import com.nextcloud.client.preferences.AppPreferences;
|
|
|
import com.owncloud.android.MainApp;
|
|
|
import com.owncloud.android.R;
|
|
|
+import com.owncloud.android.databinding.FileDetailsFragmentBinding;
|
|
|
import com.owncloud.android.datamodel.FileDataStorageManager;
|
|
|
import com.owncloud.android.datamodel.OCFile;
|
|
|
import com.owncloud.android.datamodel.ThumbnailsCacheManager;
|
|
@@ -74,10 +71,6 @@ import javax.inject.Inject;
|
|
|
import androidx.annotation.NonNull;
|
|
|
import androidx.annotation.Nullable;
|
|
|
import androidx.core.content.res.ResourcesCompat;
|
|
|
-import androidx.viewpager.widget.ViewPager;
|
|
|
-import butterknife.BindView;
|
|
|
-import butterknife.ButterKnife;
|
|
|
-import butterknife.Unbinder;
|
|
|
|
|
|
/**
|
|
|
* This Fragment is used to display the details about a file.
|
|
@@ -90,61 +83,11 @@ public class FileDetailFragment extends FileFragment implements OnClickListener,
|
|
|
private static final String ARG_FILE = "FILE";
|
|
|
private static final String ARG_USER = "USER";
|
|
|
private static final String ARG_ACTIVE_TAB = "TAB";
|
|
|
-
|
|
|
- @BindView(R.id.detail_container)
|
|
|
- LinearLayout detailContainer;
|
|
|
-
|
|
|
- @BindView(R.id.progressBlock)
|
|
|
- View downloadProgressContainer;
|
|
|
-
|
|
|
- @BindView(R.id.cancelBtn)
|
|
|
- ImageButton cancelButton;
|
|
|
-
|
|
|
- @BindView(R.id.progressBar)
|
|
|
- ProgressBar progressBar;
|
|
|
-
|
|
|
- @BindView(R.id.progressText)
|
|
|
- TextView progressText;
|
|
|
-
|
|
|
- @BindView(R.id.filename)
|
|
|
- TextView fileName;
|
|
|
-
|
|
|
- @BindView(R.id.size)
|
|
|
- TextView fileSize;
|
|
|
-
|
|
|
- @BindView(R.id.last_modification_timestamp)
|
|
|
- TextView fileModifiedTimestamp;
|
|
|
-
|
|
|
- @BindView(R.id.favorite)
|
|
|
- ImageView favoriteIcon;
|
|
|
-
|
|
|
- @BindView(R.id.overflow_menu)
|
|
|
- ImageView overflowMenu;
|
|
|
-
|
|
|
- @BindView(R.id.tab_layout)
|
|
|
- TabLayout tabLayout;
|
|
|
-
|
|
|
- @BindView(R.id.pager)
|
|
|
- ViewPager viewPager;
|
|
|
-
|
|
|
- @BindView(R.id.empty_list_view)
|
|
|
- public LinearLayout emptyContentContainer;
|
|
|
-
|
|
|
- @BindView(R.id.empty_list_view_headline)
|
|
|
- public TextView emptyContentHeadline;
|
|
|
-
|
|
|
- @BindView(R.id.empty_list_icon)
|
|
|
- public ImageView emptyContentIcon;
|
|
|
-
|
|
|
- @BindView(R.id.empty_list_progress)
|
|
|
- public ProgressBar emptyContentProgressBar;
|
|
|
-
|
|
|
- private int layout;
|
|
|
private View view;
|
|
|
private User user;
|
|
|
- private Unbinder unbinder;
|
|
|
private boolean previewLoaded;
|
|
|
|
|
|
+ private FileDetailsFragmentBinding binding;
|
|
|
private ProgressListener progressListener;
|
|
|
private ToolbarActivity toolbarActivity;
|
|
|
private int activeTab;
|
|
@@ -201,7 +144,6 @@ public class FileDetailFragment extends FileFragment implements OnClickListener,
|
|
|
public FileDetailFragment() {
|
|
|
super();
|
|
|
user = null;
|
|
|
- layout = R.layout.file_details_fragment;
|
|
|
progressListener = null;
|
|
|
}
|
|
|
|
|
@@ -211,7 +153,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener,
|
|
|
* @return reference to the {@link FileDetailSharingFragment}
|
|
|
*/
|
|
|
public FileDetailSharingFragment getFileDetailSharingFragment() {
|
|
|
- return ((FileDetailTabAdapter)viewPager.getAdapter()).getFileDetailSharingFragment();
|
|
|
+ return ((FileDetailTabAdapter) binding.pager.getAdapter()).getFileDetailSharingFragment();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -220,7 +162,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener,
|
|
|
* @return reference to the {@link FileDetailActivitiesFragment}
|
|
|
*/
|
|
|
public FileDetailActivitiesFragment getFileDetailActivitiesFragment() {
|
|
|
- return ((FileDetailTabAdapter) viewPager.getAdapter()).getFileDetailActivitiesFragment();
|
|
|
+ return ((FileDetailTabAdapter) binding.pager.getAdapter()).getFileDetailActivitiesFragment();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -247,13 +189,13 @@ public class FileDetailFragment extends FileFragment implements OnClickListener,
|
|
|
user = savedInstanceState.getParcelable(ARG_USER);
|
|
|
}
|
|
|
|
|
|
- view = inflater.inflate(layout, null);
|
|
|
- unbinder = ButterKnife.bind(this, view);
|
|
|
+ binding = FileDetailsFragmentBinding.inflate(inflater,container,false);
|
|
|
+ view = binding.getRoot();
|
|
|
|
|
|
if (getFile() == null || user == null) {
|
|
|
showEmptyContent();
|
|
|
} else {
|
|
|
- emptyContentContainer.setVisibility(View.GONE);
|
|
|
+ binding.emptyList.emptyListView.setVisibility(View.GONE);
|
|
|
}
|
|
|
|
|
|
return view;
|
|
@@ -262,12 +204,12 @@ public class FileDetailFragment extends FileFragment implements OnClickListener,
|
|
|
@Override
|
|
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
|
|
if (getFile() != null && user != null) {
|
|
|
- ThemeUtils.colorHorizontalProgressBar(progressBar, ThemeUtils.primaryAccentColor(getContext()));
|
|
|
- progressListener = new ProgressListener(progressBar);
|
|
|
- cancelButton.setOnClickListener(this);
|
|
|
- favoriteIcon.setOnClickListener(this);
|
|
|
- overflowMenu.setOnClickListener(this);
|
|
|
- fileModifiedTimestamp.setOnClickListener(this);
|
|
|
+ ThemeUtils.colorHorizontalProgressBar(binding.progressBar, ThemeUtils.primaryAccentColor(getContext()));
|
|
|
+ progressListener = new ProgressListener(binding.progressBar);
|
|
|
+ binding.cancelBtn.setOnClickListener(this);
|
|
|
+ binding.favorite.setOnClickListener(this);
|
|
|
+ binding.overflowMenu.setOnClickListener(this);
|
|
|
+ binding.lastModificationTimestamp.setOnClickListener(this);
|
|
|
|
|
|
updateFileDetails(false, false);
|
|
|
}
|
|
@@ -283,17 +225,17 @@ public class FileDetailFragment extends FileFragment implements OnClickListener,
|
|
|
}
|
|
|
|
|
|
private void setupViewPager() {
|
|
|
- tabLayout.removeAllTabs();
|
|
|
+ binding.tabLayout.removeAllTabs();
|
|
|
|
|
|
- tabLayout.addTab(tabLayout.newTab().setText(R.string.drawer_item_activities));
|
|
|
- tabLayout.addTab(tabLayout.newTab().setText(R.string.share_dialog_title));
|
|
|
+ binding.tabLayout.addTab(binding.tabLayout.newTab().setText(R.string.drawer_item_activities));
|
|
|
+ binding.tabLayout.addTab(binding.tabLayout.newTab().setText(R.string.share_dialog_title));
|
|
|
|
|
|
- tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
|
|
|
- tabLayout.setSelectedTabIndicatorColor(ThemeUtils.primaryAccentColor(getContext()));
|
|
|
+ binding.tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
|
|
|
+ binding.tabLayout.setSelectedTabIndicatorColor(ThemeUtils.primaryAccentColor(getContext()));
|
|
|
|
|
|
final FileDetailTabAdapter adapter = new FileDetailTabAdapter(getFragmentManager(), getFile(), user);
|
|
|
- viewPager.setAdapter(adapter);
|
|
|
- viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout) {
|
|
|
+ binding.pager.setAdapter(adapter);
|
|
|
+ binding.pager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(binding.tabLayout) {
|
|
|
@Override
|
|
|
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
|
|
if (activeTab == 0) {
|
|
@@ -303,10 +245,10 @@ public class FileDetailFragment extends FileFragment implements OnClickListener,
|
|
|
super.onPageScrolled(position, positionOffset, positionOffsetPixels);
|
|
|
}
|
|
|
});
|
|
|
- tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
|
|
+ binding.tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
|
|
@Override
|
|
|
public void onTabSelected(TabLayout.Tab tab) {
|
|
|
- viewPager.setCurrentItem(tab.getPosition());
|
|
|
+ binding.pager.setCurrentItem(tab.getPosition());
|
|
|
|
|
|
if (tab.getPosition() == 0) {
|
|
|
FileDetailActivitiesFragment fragment = getFileDetailActivitiesFragment();
|
|
@@ -328,7 +270,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener,
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- tabLayout.getTabAt(activeTab).select();
|
|
|
+ binding.tabLayout.getTabAt(activeTab).select();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -383,9 +325,9 @@ public class FileDetailFragment extends FileFragment implements OnClickListener,
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onDestroy() {
|
|
|
- super.onDestroy();
|
|
|
- unbinder.unbind();
|
|
|
+ public void onDestroyView() {
|
|
|
+ super.onDestroyView();
|
|
|
+ binding = null;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -504,7 +446,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener,
|
|
|
* @return True when the fragment was created with the empty layout.
|
|
|
*/
|
|
|
public boolean isEmpty() {
|
|
|
- return layout == R.layout.empty_list || getFile() == null || user == null;
|
|
|
+ return getFile() == null || user == null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -543,11 +485,11 @@ public class FileDetailFragment extends FileFragment implements OnClickListener,
|
|
|
|
|
|
// set file details
|
|
|
if (MimeTypeUtil.isImage(file)) {
|
|
|
- fileName.setText(file.getFileName());
|
|
|
+ binding.filename.setText(file.getFileName());
|
|
|
} else {
|
|
|
- fileName.setVisibility(View.GONE);
|
|
|
+ binding.filename.setVisibility(View.GONE);
|
|
|
}
|
|
|
- fileSize.setText(DisplayUtils.bytesToHumanReadable(file.getFileLength()));
|
|
|
+ binding.size.setText(DisplayUtils.bytesToHumanReadable(file.getFileLength()));
|
|
|
|
|
|
boolean showDetailedTimestamp = preferences.isShowDetailedTimestampEnabled();
|
|
|
setFileModificationTimestamp(file, showDetailedTimestamp);
|
|
@@ -581,18 +523,18 @@ public class FileDetailFragment extends FileFragment implements OnClickListener,
|
|
|
|
|
|
private void setFileModificationTimestamp(OCFile file, boolean showDetailedTimestamp) {
|
|
|
if (showDetailedTimestamp) {
|
|
|
- fileModifiedTimestamp.setText(DisplayUtils.unixTimeToHumanReadable(file.getModificationTimestamp()));
|
|
|
+ binding.lastModificationTimestamp.setText(DisplayUtils.unixTimeToHumanReadable(file.getModificationTimestamp()));
|
|
|
} else {
|
|
|
- fileModifiedTimestamp.setText(DisplayUtils.getRelativeTimestamp(getContext(),
|
|
|
+ binding.lastModificationTimestamp.setText(DisplayUtils.getRelativeTimestamp(getContext(),
|
|
|
file.getModificationTimestamp()));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void setFavoriteIconStatus(boolean isFavorite) {
|
|
|
if (isFavorite) {
|
|
|
- favoriteIcon.setImageDrawable(ResourcesCompat.getDrawable(getResources(), R.drawable.ic_star, null));
|
|
|
+ binding.favorite.setImageDrawable(ResourcesCompat.getDrawable(getResources(), R.drawable.ic_star, null));
|
|
|
} else {
|
|
|
- favoriteIcon.setImageDrawable(ResourcesCompat.getDrawable(getResources(),
|
|
|
+ binding.favorite.setImageDrawable(ResourcesCompat.getDrawable(getResources(),
|
|
|
R.drawable.ic_star_outline,
|
|
|
null));
|
|
|
}
|
|
@@ -604,7 +546,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener,
|
|
|
* @return 'True' when the fragment is ready to show details of a file
|
|
|
*/
|
|
|
private boolean readyToShow() {
|
|
|
- return getFile() != null && user != null && layout == R.layout.file_details_fragment;
|
|
|
+ return getFile() != null && user != null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -670,17 +612,17 @@ public class FileDetailFragment extends FileFragment implements OnClickListener,
|
|
|
private void setButtonsForTransferring() {
|
|
|
if (!isEmpty()) {
|
|
|
// show the progress bar for the transfer
|
|
|
- downloadProgressContainer.setVisibility(View.VISIBLE);
|
|
|
- progressText.setVisibility(View.VISIBLE);
|
|
|
+ binding.progressBlock.setVisibility(View.VISIBLE);
|
|
|
+ binding.progressText.setVisibility(View.VISIBLE);
|
|
|
FileDownloaderBinder downloaderBinder = containerActivity.getFileDownloaderBinder();
|
|
|
FileUploaderBinder uploaderBinder = containerActivity.getFileUploaderBinder();
|
|
|
//if (getFile().isDownloading()) {
|
|
|
if (downloaderBinder != null && downloaderBinder.isDownloading(user, getFile())) {
|
|
|
- progressText.setText(R.string.downloader_download_in_progress_ticker);
|
|
|
+ binding.progressText.setText(R.string.downloader_download_in_progress_ticker);
|
|
|
}
|
|
|
else {
|
|
|
if (uploaderBinder != null && uploaderBinder.isUploading(user, getFile())) {
|
|
|
- progressText.setText(R.string.uploader_upload_in_progress_ticker);
|
|
|
+ binding.progressText.setText(R.string.uploader_upload_in_progress_ticker);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -692,7 +634,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener,
|
|
|
private void setButtonsForDown() {
|
|
|
if (!isEmpty()) {
|
|
|
// hides the progress bar
|
|
|
- downloadProgressContainer.setVisibility(View.GONE);
|
|
|
+ binding.progressBlock.setVisibility(View.GONE);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -702,7 +644,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener,
|
|
|
private void setButtonsForRemote() {
|
|
|
if (!isEmpty()) {
|
|
|
// hides the progress bar
|
|
|
- downloadProgressContainer.setVisibility(View.GONE);
|
|
|
+ binding.progressBlock.setVisibility(View.GONE);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -735,16 +677,14 @@ public class FileDetailFragment extends FileFragment implements OnClickListener,
|
|
|
}
|
|
|
|
|
|
private void showEmptyContent() {
|
|
|
- if (emptyContentContainer != null) {
|
|
|
- emptyContentContainer.setVisibility(View.VISIBLE);
|
|
|
- detailContainer.setVisibility(View.GONE);
|
|
|
+ binding.emptyList.emptyListView.setVisibility(View.VISIBLE);
|
|
|
+ binding.detailContainer.setVisibility(View.GONE);
|
|
|
|
|
|
- emptyContentHeadline.setText(R.string.file_details_no_content);
|
|
|
+ binding.emptyList.emptyListViewHeadline.setText(R.string.file_details_no_content);
|
|
|
|
|
|
- emptyContentProgressBar.setVisibility(View.GONE);
|
|
|
- emptyContentIcon.setImageResource(R.drawable.ic_list_empty_error);
|
|
|
- emptyContentIcon.setVisibility(View.VISIBLE);
|
|
|
- }
|
|
|
+ binding.emptyList.emptyListProgress.setVisibility(View.GONE);
|
|
|
+ binding.emptyList.emptyListIcon.setImageResource(R.drawable.ic_list_empty_error);
|
|
|
+ binding.emptyList.emptyListIcon.setVisibility(View.VISIBLE);
|
|
|
}
|
|
|
|
|
|
/**
|