mirror of
https://github.com/nextcloud/android.git
synced 2024-11-29 10:49:04 +03:00
butterknife for details fragment + proper empty content handling
This commit is contained in:
parent
59dca8f7db
commit
6bb7dc86c7
7 changed files with 279 additions and 215 deletions
1
drawable_resources/alert-octagon.svg
Normal file
1
drawable_resources/alert-octagon.svg
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="24" height="24" viewBox="0 0 24 24"><path d="M13,13H11V7H13M12,17.3A1.3,1.3 0 0,1 10.7,16A1.3,1.3 0 0,1 12,14.7A1.3,1.3 0 0,1 13.3,16A1.3,1.3 0 0,1 12,17.3M15.73,3H8.27L3,8.27V15.73L8.27,21H15.73L21,15.73V8.27L15.73,3Z" /></svg>
|
After Width: | Height: | Size: 468 B |
|
@ -22,17 +22,21 @@
|
||||||
|
|
||||||
package com.owncloud.android.ui.activity;
|
package com.owncloud.android.ui.activity;
|
||||||
|
|
||||||
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.PorterDuff;
|
import android.graphics.PorterDuff;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.ColorInt;
|
import android.support.annotation.ColorInt;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v7.app.ActionBar;
|
import android.support.v7.app.ActionBar;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
|
|
||||||
import com.owncloud.android.R;
|
import com.owncloud.android.R;
|
||||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||||
import com.owncloud.android.datamodel.OCFile;
|
import com.owncloud.android.datamodel.OCFile;
|
||||||
|
import com.owncloud.android.datamodel.ThumbnailsCacheManager;
|
||||||
import com.owncloud.android.utils.ThemeUtils;
|
import com.owncloud.android.utils.ThemeUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -40,6 +44,7 @@ import com.owncloud.android.utils.ThemeUtils;
|
||||||
*/
|
*/
|
||||||
public abstract class ToolbarActivity extends BaseActivity {
|
public abstract class ToolbarActivity extends BaseActivity {
|
||||||
private ProgressBar mProgressBar;
|
private ProgressBar mProgressBar;
|
||||||
|
private ImageView mPreviewImage;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -66,6 +71,8 @@ public abstract class ToolbarActivity extends BaseActivity {
|
||||||
ThemeUtils.colorToolbarProgressBar(this, ThemeUtils.primaryColor(this));
|
ThemeUtils.colorToolbarProgressBar(this, ThemeUtils.primaryColor(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mPreviewImage = findViewById(R.id.preview_image);
|
||||||
|
|
||||||
ThemeUtils.colorStatusBar(this, primaryDarkColor);
|
ThemeUtils.colorStatusBar(this, primaryDarkColor);
|
||||||
|
|
||||||
if (toolbar.getOverflowIcon() != null) {
|
if (toolbar.getOverflowIcon() != null) {
|
||||||
|
@ -146,7 +153,60 @@ public abstract class ToolbarActivity extends BaseActivity {
|
||||||
* @param indeterminate <code>true</code> to enable the indeterminate mode
|
* @param indeterminate <code>true</code> to enable the indeterminate mode
|
||||||
*/
|
*/
|
||||||
public void setIndeterminate(boolean indeterminate) {
|
public void setIndeterminate(boolean indeterminate) {
|
||||||
mProgressBar.setIndeterminate(indeterminate);
|
if (mProgressBar != null) {
|
||||||
|
mProgressBar.setIndeterminate(indeterminate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change the visibility for the toolbar's progress bar.
|
||||||
|
*
|
||||||
|
* @param visibility visibility of the progress bar
|
||||||
|
*/
|
||||||
|
public void setProgressBarVisibility(int visibility) {
|
||||||
|
if (mProgressBar != null) {
|
||||||
|
mProgressBar.setVisibility(visibility);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change the visibility for the toolbar's preview image.
|
||||||
|
*
|
||||||
|
* @param visibility visibility of the preview image
|
||||||
|
*/
|
||||||
|
public void setPreviewImageVisibility(int visibility) {
|
||||||
|
if (mPreviewImage != null) {
|
||||||
|
mPreviewImage.setVisibility(visibility);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change the bitmap for the toolbar's preview image.
|
||||||
|
*
|
||||||
|
* @param bitmap bitmap of the preview image
|
||||||
|
*/
|
||||||
|
public void setPreviewImageBitmap(Bitmap bitmap) {
|
||||||
|
if (mPreviewImage != null) {
|
||||||
|
mPreviewImage.setImageBitmap(bitmap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change the drawable for the toolbar's preview image.
|
||||||
|
*
|
||||||
|
* @param drawable drawable of the preview image
|
||||||
|
*/
|
||||||
|
public void setPreviewImageDrawable(Drawable drawable) {
|
||||||
|
if (mPreviewImage != null) {
|
||||||
|
mPreviewImage.setImageDrawable(drawable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get the toolbar's preview image view.
|
||||||
|
*/
|
||||||
|
public ImageView getPreviewImageView() {
|
||||||
|
return mPreviewImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -22,10 +22,11 @@
|
||||||
package com.owncloud.android.ui.fragment;
|
package com.owncloud.android.ui.fragment;
|
||||||
|
|
||||||
import android.accounts.Account;
|
import android.accounts.Account;
|
||||||
|
import android.content.Context;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
import android.support.design.widget.Snackbar;
|
import android.support.design.widget.Snackbar;
|
||||||
import android.support.design.widget.TabLayout;
|
import android.support.design.widget.TabLayout;
|
||||||
import android.support.v4.view.ViewPager;
|
import android.support.v4.view.ViewPager;
|
||||||
|
@ -35,7 +36,9 @@ import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
import android.widget.PopupMenu;
|
import android.widget.PopupMenu;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
@ -62,21 +65,15 @@ import com.owncloud.android.utils.ThemeUtils;
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
|
|
||||||
|
import butterknife.BindView;
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
import butterknife.Optional;
|
||||||
|
import butterknife.Unbinder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This Fragment is used to display the details about a file.
|
* This Fragment is used to display the details about a file.
|
||||||
*/
|
*/
|
||||||
public class FileDetailFragment extends FileFragment implements OnClickListener {
|
public class FileDetailFragment extends FileFragment implements OnClickListener {
|
||||||
|
|
||||||
private int layout;
|
|
||||||
private View view;
|
|
||||||
private ImageView previewImage;
|
|
||||||
private ProgressBar toolbarProgressBar;
|
|
||||||
private boolean previewLoaded;
|
|
||||||
private Account account;
|
|
||||||
|
|
||||||
public ProgressListener progressListener;
|
|
||||||
|
|
||||||
private static final String TAG = FileDetailFragment.class.getSimpleName();
|
private static final String TAG = FileDetailFragment.class.getSimpleName();
|
||||||
public static final String FTAG_CONFIRMATION = "REMOVE_CONFIRMATION_FRAGMENT";
|
public static final String FTAG_CONFIRMATION = "REMOVE_CONFIRMATION_FRAGMENT";
|
||||||
public static final String FTAG_RENAME_FILE = "RENAME_FILE_FRAGMENT";
|
public static final String FTAG_RENAME_FILE = "RENAME_FILE_FRAGMENT";
|
||||||
|
@ -84,6 +81,60 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
|
||||||
private static final String ARG_FILE = "FILE";
|
private static final String ARG_FILE = "FILE";
|
||||||
private static final String ARG_ACCOUNT = "ACCOUNT";
|
private static final String ARG_ACCOUNT = "ACCOUNT";
|
||||||
|
|
||||||
|
@Nullable @BindView(R.id.fdProgressBlock)
|
||||||
|
View downloadProgressContainer;
|
||||||
|
|
||||||
|
@Nullable @BindView(R.id.fdCancelBtn)
|
||||||
|
ImageButton cancelButton;
|
||||||
|
|
||||||
|
@Nullable @BindView(R.id.fdProgressBar)
|
||||||
|
ProgressBar progressBar;
|
||||||
|
|
||||||
|
@Nullable @BindView(R.id.fdProgressText)
|
||||||
|
TextView progressText;
|
||||||
|
|
||||||
|
@Nullable @BindView(R.id.fdFilename)
|
||||||
|
TextView fileName;
|
||||||
|
|
||||||
|
@Nullable @BindView(R.id.fdSize)
|
||||||
|
TextView fileSize;
|
||||||
|
|
||||||
|
@Nullable @BindView(R.id.fdModified)
|
||||||
|
TextView fileModifiedTimestamp;
|
||||||
|
|
||||||
|
@Nullable @BindView(R.id.fdFavorite)
|
||||||
|
ImageView favoriteIcon;
|
||||||
|
|
||||||
|
@Nullable @BindView(R.id.overflow_menu)
|
||||||
|
ImageView overflowMenu;
|
||||||
|
|
||||||
|
@Nullable @BindView(R.id.tab_layout)
|
||||||
|
TabLayout tabLayout;
|
||||||
|
|
||||||
|
@Nullable @BindView(R.id.pager)
|
||||||
|
ViewPager viewPager;
|
||||||
|
|
||||||
|
@Nullable @BindView(R.id.empty_list_view_text)
|
||||||
|
protected TextView emptyContentMessage;
|
||||||
|
|
||||||
|
@Nullable @BindView(R.id.empty_list_view_headline)
|
||||||
|
protected TextView emptyContentHeadline;
|
||||||
|
|
||||||
|
@Nullable @BindView(R.id.empty_list_icon)
|
||||||
|
protected ImageView emptyContentIcon;
|
||||||
|
|
||||||
|
@Nullable @BindView(R.id.empty_list_progress)
|
||||||
|
protected ProgressBar emptyProgressBar;
|
||||||
|
|
||||||
|
private int layout;
|
||||||
|
private View view;
|
||||||
|
private boolean previewLoaded;
|
||||||
|
private Account account;
|
||||||
|
private Unbinder unbinder;
|
||||||
|
|
||||||
|
public ProgressListener progressListener;
|
||||||
|
private ToolbarActivity activity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Public factory method to create new FileDetailFragment instances.
|
* Public factory method to create new FileDetailFragment instances.
|
||||||
*
|
*
|
||||||
|
@ -111,7 +162,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
|
||||||
public FileDetailFragment() {
|
public FileDetailFragment() {
|
||||||
super();
|
super();
|
||||||
account = null;
|
account = null;
|
||||||
layout = R.layout.file_details_empty;
|
layout = R.layout.empty_list;
|
||||||
progressListener = null;
|
progressListener = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,17 +170,21 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
if (previewImage != null && MimeTypeUtil.isImage(getFile()) && previewLoaded) {
|
if (getFile()!= null && MimeTypeUtil.isImage(getFile()) && previewLoaded) {
|
||||||
activatePreviewImage();
|
activatePreviewImage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void activatePreviewImage() {
|
private void activatePreviewImage() {
|
||||||
previewImage.setVisibility(View.VISIBLE);
|
if (activity != null) {
|
||||||
toolbarProgressBar.setVisibility(View.GONE);
|
activity.setPreviewImageVisibility(View.VISIBLE);
|
||||||
((ToolbarActivity) getActivity()).getSupportActionBar().setTitle(null);
|
activity.setProgressBarVisibility(View.GONE);
|
||||||
((ToolbarActivity) getActivity()).getSupportActionBar().setBackgroundDrawable(null);
|
ThemeUtils.setStatusBarColor(activity, activity.getResources().getColor(R.color.black));
|
||||||
makeStatusBarBlack();
|
if (activity.getSupportActionBar() != null) {
|
||||||
|
activity.getSupportActionBar().setTitle(null);
|
||||||
|
activity.getSupportActionBar().setBackgroundDrawable(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -150,32 +205,40 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
|
||||||
account = savedInstanceState.getParcelable(FileActivity.EXTRA_ACCOUNT);
|
account = savedInstanceState.getParcelable(FileActivity.EXTRA_ACCOUNT);
|
||||||
}
|
}
|
||||||
|
|
||||||
toolbarProgressBar = getActivity().findViewById(R.id.progressBar);
|
|
||||||
|
|
||||||
if (getFile() != null && account != null) {
|
if (getFile() != null && account != null) {
|
||||||
layout = R.layout.file_details_fragment;
|
layout = R.layout.file_details_fragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
view = inflater.inflate(layout, null);
|
view = inflater.inflate(layout, null);
|
||||||
|
unbinder = ButterKnife.bind(this, view);
|
||||||
if (layout == R.layout.file_details_fragment) {
|
|
||||||
ProgressBar progressBar = view.findViewById(R.id.fdProgressBar);
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||||
|
if (getFile() != null && account != null) {
|
||||||
ThemeUtils.colorHorizontalProgressBar(progressBar, ThemeUtils.primaryAccentColor(getContext()));
|
ThemeUtils.colorHorizontalProgressBar(progressBar, ThemeUtils.primaryAccentColor(getContext()));
|
||||||
progressListener = new ProgressListener(progressBar);
|
progressListener = new ProgressListener(progressBar);
|
||||||
view.findViewById(R.id.fdCancelBtn).setOnClickListener(this);
|
cancelButton.setOnClickListener(this);
|
||||||
view.findViewById(R.id.fdFavorite).setOnClickListener(this);
|
favoriteIcon.setOnClickListener(this);
|
||||||
view.findViewById(R.id.overflow_menu).setOnClickListener(this);
|
overflowMenu.setOnClickListener(this);
|
||||||
previewImage = getActivity().findViewById(R.id.preview_image);
|
|
||||||
// TODO use whenever we switch to use glide for preview images
|
// TODO use whenever we switch to use glide for preview images
|
||||||
/*
|
/*
|
||||||
if (getFile() != null && account != null && MimeTypeUtil.isImage(getFile())) {
|
if (MimeTypeUtil.isImage(getFile())) {
|
||||||
setHeaderImage();
|
setHeaderImage();
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
|
||||||
|
|
||||||
updateFileDetails(false, false);
|
updateFileDetails(false, false);
|
||||||
return view;
|
} else {
|
||||||
|
emptyContentMessage.setText(R.string.filedetails_select_file);
|
||||||
|
emptyContentMessage.setVisibility(View.VISIBLE);
|
||||||
|
emptyContentHeadline.setText(R.string.common_error);
|
||||||
|
emptyContentIcon.setImageDrawable(getContext().getResources().getDrawable(R.drawable.ic_alert_octagon));
|
||||||
|
emptyContentIcon.setVisibility(View.VISIBLE);
|
||||||
|
emptyProgressBar.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// TODO use whenever we switch to use glide for preview images
|
// TODO use whenever we switch to use glide for preview images
|
||||||
/*
|
/*
|
||||||
|
@ -236,8 +299,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
|
||||||
popup.show();
|
popup.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupViewPager(View view) {
|
private void setupViewPager() {
|
||||||
TabLayout tabLayout = view.findViewById(R.id.tab_layout);
|
|
||||||
tabLayout.removeAllTabs();
|
tabLayout.removeAllTabs();
|
||||||
|
|
||||||
tabLayout.addTab(tabLayout.newTab().setText(R.string.drawer_item_activities));
|
tabLayout.addTab(tabLayout.newTab().setText(R.string.drawer_item_activities));
|
||||||
|
@ -246,7 +308,6 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
|
||||||
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
|
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
|
||||||
tabLayout.setSelectedTabIndicatorColor(ThemeUtils.primaryAccentColor(getContext()));
|
tabLayout.setSelectedTabIndicatorColor(ThemeUtils.primaryAccentColor(getContext()));
|
||||||
|
|
||||||
final ViewPager viewPager = view.findViewById(R.id.pager);
|
|
||||||
final FileDetailTabAdapter adapter = new FileDetailTabAdapter
|
final FileDetailTabAdapter adapter = new FileDetailTabAdapter
|
||||||
(getFragmentManager(), getFile(), account);
|
(getFragmentManager(), getFile(), account);
|
||||||
viewPager.setAdapter(adapter);
|
viewPager.setAdapter(adapter);
|
||||||
|
@ -285,17 +346,32 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
|
||||||
@Override
|
@Override
|
||||||
public void onStop() {
|
public void onStop() {
|
||||||
leaveTransferProgress();
|
leaveTransferProgress();
|
||||||
if (previewImage != null) {
|
|
||||||
previewImage.setVisibility(View.GONE);
|
if(activity != null) {
|
||||||
toolbarProgressBar.setVisibility(View.VISIBLE);
|
activity.setPreviewImageVisibility(View.GONE);
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
activity.setProgressBarVisibility(View.VISIBLE);
|
||||||
getActivity().getWindow().setStatusBarColor(ThemeUtils.primaryDarkColor(getContext()));
|
ThemeUtils.setStatusBarColor(activity, ThemeUtils.primaryColor(getContext()));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
super.onStop();
|
super.onStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttach(Context context) {
|
||||||
|
super.onAttach(context);
|
||||||
|
if (context instanceof ToolbarActivity) {
|
||||||
|
activity = (ToolbarActivity) context;
|
||||||
|
} else {
|
||||||
|
activity = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
unbinder.unbind();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View getView() {
|
public View getView() {
|
||||||
return super.getView() == null ? view : super.getView();
|
return super.getView() == null ? view : super.getView();
|
||||||
|
@ -405,16 +481,11 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
|
||||||
}
|
}
|
||||||
case R.id.fdFavorite: {
|
case R.id.fdFavorite: {
|
||||||
if (getFile().getIsFavorite()) {
|
if (getFile().getIsFavorite()) {
|
||||||
((ImageView)getView().findViewById(R.id.fdFavorite)).
|
|
||||||
setImageDrawable(getResources()
|
|
||||||
.getDrawable(R.drawable.ic_star_outline));
|
|
||||||
mContainerActivity.getFileOperationsHelper().toggleFavoriteFile(getFile(), false);
|
mContainerActivity.getFileOperationsHelper().toggleFavoriteFile(getFile(), false);
|
||||||
} else {
|
} else {
|
||||||
((ImageView)getView().findViewById(R.id.fdFavorite))
|
|
||||||
.setImageDrawable(getResources()
|
|
||||||
.getDrawable(R.drawable.ic_star));
|
|
||||||
mContainerActivity.getFileOperationsHelper().toggleFavoriteFile(getFile(), true);
|
mContainerActivity.getFileOperationsHelper().toggleFavoriteFile(getFile(), true);
|
||||||
}
|
}
|
||||||
|
setFavoriteIconStatus(!getFile().getIsFavorite());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case R.id.overflow_menu: {
|
case R.id.overflow_menu: {
|
||||||
|
@ -433,7 +504,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
|
||||||
* @return True when the fragment was created with the empty layout.
|
* @return True when the fragment was created with the empty layout.
|
||||||
*/
|
*/
|
||||||
public boolean isEmpty() {
|
public boolean isEmpty() {
|
||||||
return (layout == R.layout.file_details_empty || getFile() == null || account == null);
|
return (layout == R.layout.empty_list || getFile() == null || account == null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -471,16 +542,15 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
|
||||||
OCFile file = getFile();
|
OCFile file = getFile();
|
||||||
|
|
||||||
// set file details
|
// set file details
|
||||||
setFilename(file.getFileName());
|
if (MimeTypeUtil.isImage(file)) {
|
||||||
setFiletype(file);
|
fileName.setText(file.getFileName());
|
||||||
setFilesize(file.getFileLength());
|
|
||||||
setTimeModified(file.getModificationTimestamp());
|
|
||||||
|
|
||||||
if (file.getIsFavorite()) {
|
|
||||||
((ImageView)getView().findViewById(R.id.fdFavorite)).setImageDrawable(getResources().getDrawable(R.drawable.ic_star));
|
|
||||||
} else {
|
} else {
|
||||||
((ImageView)getView().findViewById(R.id.fdFavorite)).setImageDrawable(getResources().getDrawable(R.drawable.ic_star_outline));
|
fileName.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
fileSize.setText(DisplayUtils.bytesToHumanReadable(file.getFileLength()));
|
||||||
|
fileModifiedTimestamp.setText(DisplayUtils.unixTimeToHumanReadable(file.getModificationTimestamp()));
|
||||||
|
setFilePreview(file);
|
||||||
|
setFavoriteIconStatus(file.getIsFavorite());
|
||||||
|
|
||||||
// configure UI for depending upon local state of the file
|
// configure UI for depending upon local state of the file
|
||||||
FileDownloaderBinder downloaderBinder = mContainerActivity.getFileDownloaderBinder();
|
FileDownloaderBinder downloaderBinder = mContainerActivity.getFileDownloaderBinder();
|
||||||
|
@ -502,11 +572,19 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setupViewPager(getView());
|
setupViewPager();
|
||||||
|
|
||||||
getView().invalidate();
|
getView().invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setFavoriteIconStatus(boolean isFavorite) {
|
||||||
|
if (isFavorite) {
|
||||||
|
favoriteIcon.setImageDrawable(getResources().getDrawable(R.drawable.ic_star));
|
||||||
|
} else {
|
||||||
|
favoriteIcon.setImageDrawable(getResources().getDrawable(R.drawable.ic_star_outline));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the fragment is ready to show details of a OCFile
|
* Checks if the fragment is ready to show details of a OCFile
|
||||||
*
|
*
|
||||||
|
@ -517,124 +595,68 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the filename in view
|
* Updates the file preview if possible
|
||||||
*
|
*
|
||||||
* @param filename to set
|
* @param file a {@link OCFile} to be previewed
|
||||||
*/
|
*/
|
||||||
private void setFilename(String filename) {
|
private void setFilePreview(OCFile file) {
|
||||||
TextView tv = getView().findViewById(R.id.fdFilename);
|
Bitmap resizedImage;
|
||||||
if (tv != null) {
|
|
||||||
tv.setText(filename);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
if (MimeTypeUtil.isImage(file) && activity != null) {
|
||||||
* Updates the MIME type in view
|
String tagId = String.valueOf(ThumbnailsCacheManager.PREFIX_RESIZED_IMAGE + getFile().getRemoteId());
|
||||||
* @param file : An {@link OCFile}
|
resizedImage = ThumbnailsCacheManager.getBitmapFromDiskCache(tagId);
|
||||||
*/
|
|
||||||
private void setFiletype(OCFile file) {
|
|
||||||
ImageView iv = getView().findViewById(R.id.fdIcon);
|
|
||||||
View v = getView().findViewById(R.id.fdIcon_divider);
|
|
||||||
|
|
||||||
if (iv != null) {
|
if (resizedImage != null && !file.needsUpdateThumbnail()) {
|
||||||
iv.setTag(file.getFileId());
|
activity.setPreviewImageBitmap(resizedImage);
|
||||||
// Name of the file, to deduce the icon to use in case the MIME type is not precise enough
|
activatePreviewImage();
|
||||||
iv.setImageDrawable(MimeTypeUtil.getFileTypeIcon(file.getMimetype(), file.getFileName(), account,
|
previewLoaded = true;
|
||||||
getContext()));
|
} else {
|
||||||
|
// show thumbnail while loading resized image
|
||||||
|
Bitmap thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache(
|
||||||
|
String.valueOf(ThumbnailsCacheManager.PREFIX_THUMBNAIL + getFile().getRemoteId()));
|
||||||
|
|
||||||
Bitmap resizedImage;
|
if (thumbnail != null) {
|
||||||
|
activity.setPreviewImageBitmap(thumbnail);
|
||||||
|
} else {
|
||||||
|
thumbnail = ThumbnailsCacheManager.mDefaultImg;
|
||||||
|
}
|
||||||
|
|
||||||
if (MimeTypeUtil.isImage(file)) {
|
// generate new resized image
|
||||||
String tagId = String.valueOf(ThumbnailsCacheManager.PREFIX_RESIZED_IMAGE + getFile().getRemoteId());
|
if (ThumbnailsCacheManager.cancelPotentialThumbnailWork(getFile(), activity.getPreviewImageView()) &&
|
||||||
resizedImage = ThumbnailsCacheManager.getBitmapFromDiskCache(tagId);
|
mContainerActivity.getStorageManager() != null) {
|
||||||
|
final ThumbnailsCacheManager.ResizedImageGenerationTask task =
|
||||||
|
new ThumbnailsCacheManager.ResizedImageGenerationTask(FileDetailFragment.this,
|
||||||
|
activity.getPreviewImageView(),
|
||||||
|
mContainerActivity.getStorageManager(),
|
||||||
|
mContainerActivity.getStorageManager().getAccount());
|
||||||
|
|
||||||
if (resizedImage != null && !file.needsUpdateThumbnail()) {
|
if (resizedImage == null) {
|
||||||
iv.setVisibility(View.GONE);
|
resizedImage = thumbnail;
|
||||||
v.setVisibility(View.GONE);
|
}
|
||||||
previewImage.setImageBitmap(resizedImage);
|
|
||||||
|
final ThumbnailsCacheManager.AsyncResizedImageDrawable asyncDrawable =
|
||||||
|
new ThumbnailsCacheManager.AsyncResizedImageDrawable(
|
||||||
|
MainApp.getAppContext().getResources(),
|
||||||
|
resizedImage,
|
||||||
|
task
|
||||||
|
);
|
||||||
|
|
||||||
|
activity.setPreviewImageDrawable(asyncDrawable);
|
||||||
activatePreviewImage();
|
activatePreviewImage();
|
||||||
previewLoaded = true;
|
previewLoaded = true;
|
||||||
} else {
|
task.execute(getFile());
|
||||||
// show thumbnail while loading resized image
|
|
||||||
Bitmap thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache(
|
|
||||||
String.valueOf(ThumbnailsCacheManager.PREFIX_THUMBNAIL + getFile().getRemoteId()));
|
|
||||||
|
|
||||||
if (thumbnail != null) {
|
|
||||||
iv.setImageBitmap(thumbnail);
|
|
||||||
} else {
|
|
||||||
thumbnail = ThumbnailsCacheManager.mDefaultImg;
|
|
||||||
}
|
|
||||||
|
|
||||||
// generate new resized image
|
|
||||||
if (ThumbnailsCacheManager.cancelPotentialThumbnailWork(getFile(), iv) &&
|
|
||||||
mContainerActivity.getStorageManager() != null) {
|
|
||||||
final ThumbnailsCacheManager.ResizedImageGenerationTask task =
|
|
||||||
new ThumbnailsCacheManager.ResizedImageGenerationTask(FileDetailFragment.this,
|
|
||||||
iv,
|
|
||||||
mContainerActivity.getStorageManager(),
|
|
||||||
mContainerActivity.getStorageManager().getAccount());
|
|
||||||
if (resizedImage == null) {
|
|
||||||
resizedImage = thumbnail;
|
|
||||||
}
|
|
||||||
final ThumbnailsCacheManager.AsyncResizedImageDrawable asyncDrawable =
|
|
||||||
new ThumbnailsCacheManager.AsyncResizedImageDrawable(
|
|
||||||
MainApp.getAppContext().getResources(),
|
|
||||||
resizedImage,
|
|
||||||
task
|
|
||||||
);
|
|
||||||
iv.setVisibility(View.GONE);
|
|
||||||
v.setVisibility(View.GONE);
|
|
||||||
previewImage.setImageDrawable(asyncDrawable);
|
|
||||||
activatePreviewImage();
|
|
||||||
previewLoaded = true;
|
|
||||||
task.execute(getFile());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
iv.setImageDrawable(MimeTypeUtil.getFileTypeIcon(file.getMimetype(), file.getFileName(), account,
|
|
||||||
getContext()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void makeStatusBarBlack() {
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
|
||||||
getActivity().getWindow().setStatusBarColor(getResources().getColor(R.color.black));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the file size in view
|
|
||||||
*
|
|
||||||
* @param fileSize in bytes to set
|
|
||||||
*/
|
|
||||||
private void setFilesize(long fileSize) {
|
|
||||||
TextView tv = getView().findViewById(R.id.fdSize);
|
|
||||||
if (tv != null) {
|
|
||||||
tv.setText(DisplayUtils.bytesToHumanReadable(fileSize));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the time that the file was last modified
|
|
||||||
*
|
|
||||||
* @param milliseconds Unix time to set
|
|
||||||
*/
|
|
||||||
private void setTimeModified(long milliseconds) {
|
|
||||||
TextView tv = getView().findViewById(R.id.fdModified);
|
|
||||||
if (tv != null) {
|
|
||||||
tv.setText(DisplayUtils.unixTimeToHumanReadable(milliseconds));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enables or disables buttons for a file being downloaded
|
* Enables or disables buttons for a file being downloaded
|
||||||
*/
|
*/
|
||||||
private void setButtonsForTransferring() {
|
private void setButtonsForTransferring() {
|
||||||
if (!isEmpty()) {
|
if (!isEmpty()) {
|
||||||
// show the progress bar for the transfer
|
// show the progress bar for the transfer
|
||||||
getView().findViewById(R.id.fdProgressBlock).setVisibility(View.VISIBLE);
|
downloadProgressContainer.setVisibility(View.VISIBLE);
|
||||||
TextView progressText = getView().findViewById(R.id.fdProgressText);
|
|
||||||
progressText.setVisibility(View.VISIBLE);
|
progressText.setVisibility(View.VISIBLE);
|
||||||
FileDownloaderBinder downloaderBinder = mContainerActivity.getFileDownloaderBinder();
|
FileDownloaderBinder downloaderBinder = mContainerActivity.getFileDownloaderBinder();
|
||||||
FileUploaderBinder uploaderBinder = mContainerActivity.getFileUploaderBinder();
|
FileUploaderBinder uploaderBinder = mContainerActivity.getFileUploaderBinder();
|
||||||
|
@ -656,9 +678,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
|
||||||
private void setButtonsForDown() {
|
private void setButtonsForDown() {
|
||||||
if (!isEmpty()) {
|
if (!isEmpty()) {
|
||||||
// hides the progress bar
|
// hides the progress bar
|
||||||
getView().findViewById(R.id.fdProgressBlock).setVisibility(View.GONE);
|
downloadProgressContainer.setVisibility(View.GONE);
|
||||||
TextView progressText = getView().findViewById(R.id.fdProgressText);
|
|
||||||
progressText.setVisibility(View.GONE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -668,9 +688,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
|
||||||
private void setButtonsForRemote() {
|
private void setButtonsForRemote() {
|
||||||
if (!isEmpty()) {
|
if (!isEmpty()) {
|
||||||
// hides the progress bar
|
// hides the progress bar
|
||||||
getView().findViewById(R.id.fdProgressBlock).setVisibility(View.GONE);
|
downloadProgressContainer.setVisibility(View.GONE);
|
||||||
TextView progressText = getView().findViewById(R.id.fdProgressText);
|
|
||||||
progressText.setVisibility(View.GONE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -706,25 +724,25 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
|
||||||
* Helper class responsible for updating the progress bar shown for file downloading.
|
* Helper class responsible for updating the progress bar shown for file downloading.
|
||||||
*/
|
*/
|
||||||
private class ProgressListener implements OnDatatransferProgressListener {
|
private class ProgressListener implements OnDatatransferProgressListener {
|
||||||
private int mLastPercent = 0;
|
private int lastPercent = 0;
|
||||||
private WeakReference<ProgressBar> mProgressBar;
|
private WeakReference<ProgressBar> progressBarReference;
|
||||||
|
|
||||||
ProgressListener(ProgressBar progressBar) {
|
ProgressListener(ProgressBar progressBar) {
|
||||||
mProgressBar = new WeakReference<>(progressBar);
|
progressBarReference = new WeakReference<>(progressBar);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTransferProgress(long progressRate, long totalTransferredSoFar,
|
public void onTransferProgress(long progressRate, long totalTransferredSoFar,
|
||||||
long totalToTransfer, String filename) {
|
long totalToTransfer, String filename) {
|
||||||
int percent = (int)(100.0*((double)totalTransferredSoFar)/((double)totalToTransfer));
|
int percent = (int)(100.0*((double)totalTransferredSoFar)/((double)totalToTransfer));
|
||||||
if (percent != mLastPercent) {
|
if (percent != lastPercent) {
|
||||||
ProgressBar pb = mProgressBar.get();
|
ProgressBar pb = progressBarReference.get();
|
||||||
if (pb != null) {
|
if (pb != null) {
|
||||||
pb.setProgress(percent);
|
pb.setProgress(percent);
|
||||||
pb.postInvalidate();
|
pb.postInvalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mLastPercent = percent;
|
lastPercent = percent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
package com.owncloud.android.utils;
|
package com.owncloud.android.utils;
|
||||||
|
|
||||||
import android.accounts.Account;
|
import android.accounts.Account;
|
||||||
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
|
@ -44,6 +45,7 @@ import android.support.v7.widget.AppCompatCheckBox;
|
||||||
import android.support.v7.widget.SwitchCompat;
|
import android.support.v7.widget.SwitchCompat;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
|
import android.view.Window;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.SeekBar;
|
import android.widget.SeekBar;
|
||||||
|
@ -212,6 +214,12 @@ public class ThemeUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setStatusBarColor(Activity activity, @ColorInt int color) {
|
||||||
|
if (activity != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
|
activity.getWindow().setStatusBarColor(color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adjust lightness of given color
|
* Adjust lightness of given color
|
||||||
*
|
*
|
||||||
|
|
23
src/main/res/drawable/ic_alert_octagon.xml
Normal file
23
src/main/res/drawable/ic_alert_octagon.xml
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
<!--
|
||||||
|
@author Google LLC
|
||||||
|
Copyright (C) 2018 Google LLC
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:height="24dp"
|
||||||
|
android:width="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path android:fillColor="#757575" android:pathData="M13,13H11V7H13M12,17.3A1.3,1.3 0 0,1 10.7,16A1.3,1.3 0 0,1 12,14.7A1.3,1.3 0 0,1 13.3,16A1.3,1.3 0 0,1 12,17.3M15.73,3H8.27L3,8.27V15.73L8.27,21H15.73L21,15.73V8.27L15.73,3Z" />
|
||||||
|
</vector>
|
|
@ -1,32 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
ownCloud Android client application
|
|
||||||
|
|
||||||
Copyright (C) 2012 Bartek Przybylski
|
|
||||||
Copyright (C) 2015 ownCloud Inc.
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License version 2,
|
|
||||||
as published by the Free Software Foundation.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
-->
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="fill_parent"
|
|
||||||
android:gravity="center_vertical|center_horizontal"
|
|
||||||
android:text="@string/filedetails_select_file"
|
|
||||||
/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
|
@ -29,27 +29,13 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/fdIcon"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_margin="@dimen/standard_margin"
|
|
||||||
android:contentDescription="@string/file_icon"
|
|
||||||
android:src="@drawable/file" />
|
|
||||||
|
|
||||||
<View
|
|
||||||
android:id="@+id/fdIcon_divider"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="1dp"
|
|
||||||
android:background="@color/list_divider_background" />
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingTop="@dimen/standard_padding"
|
android:paddingTop="@dimen/standard_padding"
|
||||||
android:paddingLeft="@dimen/standard_padding"
|
android:paddingLeft="@dimen/standard_padding"
|
||||||
android:paddingRight="@dimen/standard_padding"
|
android:paddingRight="@dimen/standard_padding"
|
||||||
android:paddingBottom="@dimen/standard_half_padding"
|
android:paddingBottom="@dimen/standard_padding"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
@ -144,6 +130,7 @@
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/fdProgressBlock"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingLeft="@dimen/standard_padding"
|
android:paddingLeft="@dimen/standard_padding"
|
||||||
|
@ -158,7 +145,6 @@
|
||||||
android:text="@string/downloader_download_in_progress_ticker" />
|
android:text="@string/downloader_download_in_progress_ticker" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/fdProgressBlock"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="@dimen/standard_quarter_margin"
|
android:layout_marginBottom="@dimen/standard_quarter_margin"
|
||||||
|
|
Loading…
Reference in a new issue