Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* ownCloud Android client application
*
* @author Bartek Przybylski
Expand Down Expand Up @@ -57,6 +57,9 @@
import com.owncloud.android.utils.MimetypeIconUtil;
import com.owncloud.android.utils.PreferenceUtils;

import org.jetbrains.annotations.NotNull;


/**
* This Fragment is used to display the details about a file.
*/
Expand All @@ -76,7 +79,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener

/**
* Public factory method to create new FileDetailFragment instances.
*
* <p>
* When 'fileToDetail' or 'ocAccount' are null, creates a dummy layout (to use when a file wasn't tapped before).
*
* @param fileToDetail An {@link OCFile} to show in the fragment
Expand All @@ -94,7 +97,7 @@ public static FileDetailFragment newInstance(OCFile fileToDetail, Account accoun

/**
* Creates an empty details fragment.
*
* <p>
* It's necessary to keep a public constructor without parameters; the system uses it when tries
* to reinstantiate a fragment automatically.
*/
Expand All @@ -106,7 +109,7 @@ public FileDetailFragment() {

@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.onActivityCreated(savedInstanceState);
setHasOptionsMenu(true);
mProgressController = new TransferProgressController((ComponentsGetter) getActivity());
ProgressBar progressBar = mView.findViewById(R.id.fdProgressBar);
Expand All @@ -128,8 +131,7 @@ public void onActivityCreated(Bundle savedInstanceState) {
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
public View onCreateView(@NotNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

setFile(getArguments().getParcelable(ARG_FILE));
mAccount = getArguments().getParcelable(ARG_ACCOUNT);
Expand All @@ -154,7 +156,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
}

@Override
public void onSaveInstanceState(Bundle outState) {
public void onSaveInstanceState(@NotNull Bundle outState) {
super.onSaveInstanceState(outState);
outState.putParcelable(FileActivity.EXTRA_FILE, getFile());
outState.putParcelable(FileActivity.EXTRA_ACCOUNT, mAccount);
Expand Down Expand Up @@ -367,9 +369,9 @@ public boolean isEmpty() {
* Updates the view with all relevant details about that file.
*
* @param forcedTransferring Flag signaling if the file should be considered as downloading or uploading,
* although {@link FileDownloaderBinder#isDownloading(Account, OCFile)} and
* {@link FileUploaderBinder#isUploading(Account, OCFile)} return false.
* @param refresh If 'true', try to refresh the whole file from the database
* although {@link FileDownloaderBinder#isDownloading(Account, OCFile)} and
* {@link FileUploaderBinder#isUploading(Account, OCFile)} return false.
* @param refresh If 'true', try to refresh the whole file from the database
*/
private void updateFileDetails(boolean forcedTransferring, boolean refresh) {
if (readyToShow()) {
Expand Down Expand Up @@ -431,6 +433,7 @@ private void setFilename(String filename) {

/**
* Updates the MIME type in view
*
* @param file : An {@link OCFile}
*/
private void setFiletype(OCFile file) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,23 @@ private static class FixedViewInfo {
* The view to add to the grid
*/
public View view;
public ViewGroup viewContainer;
ViewGroup viewContainer;
/**
* The data backing the view. This is returned from {@link android.widget.ListAdapter#getItem(int)}.
*/
public Object data;
/**
* <code>true</code> if the fixed view should be selectable in the grid
*/
public boolean isSelectable;
boolean isSelectable;
}

private int mNumColumns = AUTO_FIT;
private View mViewForMeasureRowHeight = null;
private int mRowHeight = -1;
private static final String LOG_TAG = "grid-view-with-header-and-footer";
private static final String LOG_TAG = "grid-view-header-footer";

private ArrayList<FixedViewInfo> mHeaderViewInfos = new ArrayList<FixedViewInfo>();
private ArrayList<FixedViewInfo> mFooterViewInfos = new ArrayList<FixedViewInfo>();
private ArrayList<FixedViewInfo> mHeaderViewInfos = new ArrayList<>();
private ArrayList<FixedViewInfo> mFooterViewInfos = new ArrayList<>();

private void initHeaderGridView() {
}
Expand All @@ -96,7 +95,7 @@ public GridViewWithHeaderAndFooter(Context context, AttributeSet attrs, int defS
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
ListAdapter adapter = getAdapter();
if (adapter != null && adapter instanceof HeaderViewGridAdapter) {
if (adapter instanceof HeaderViewGridAdapter) {
((HeaderViewGridAdapter) adapter).setNumColumns(getNumColumnsCompatible());
invalidateRowHeight();
((HeaderViewGridAdapter) adapter).setRowHeight(getRowHeight());
Expand All @@ -108,15 +107,6 @@ public void setClipChildren(boolean clipChildren) {
// Ignore, since the header rows depend on not being clipped
}

/**
* Do not call this method unless you know how it works.
*
* @param clipChildren
*/
public void setClipChildrenSupper(boolean clipChildren) {
super.setClipChildren(false);
}

/**
* Add a fixed view to appear at the top of the grid. If addHeaderView is
* called more than once, the views will appear in the order they were
Expand Down Expand Up @@ -263,23 +253,8 @@ private void removeFixedViewInfo(View v, ArrayList<FixedViewInfo> where) {
}
}

@TargetApi(11)
private int getNumColumnsCompatible() {
if (Build.VERSION.SDK_INT >= 11) {
return super.getNumColumns();
} else {
try {
Field numColumns = getClass().getSuperclass().getDeclaredField("mNumColumns");
numColumns.setAccessible(true);
return numColumns.getInt(this);
} catch (Exception e) {
if (mNumColumns != -1) {
return mNumColumns;
}
throw new RuntimeException("Can not determine the mNumColumns for this API platform, please call " +
"setNumColumns to set it.");
}
}
return super.getNumColumns();
}

@TargetApi(16)
Expand Down Expand Up @@ -337,24 +312,14 @@ public int getRowHeight() {
return mRowHeight;
}

@TargetApi(11)
public void tryToScrollToBottomSmoothly() {
int lastPos = getAdapter().getCount() - 1;
if (Build.VERSION.SDK_INT >= 11) {
smoothScrollToPositionFromTop(lastPos, 0);
} else {
setSelection(lastPos);
}
smoothScrollToPositionFromTop(lastPos, 0);
}

@TargetApi(11)
public void tryToScrollToBottomSmoothly(int duration) {
int lastPos = getAdapter().getCount() - 1;
if (Build.VERSION.SDK_INT >= 11) {
smoothScrollToPositionFromTop(lastPos, 0, duration);
} else {
setSelection(lastPos);
}
smoothScrollToPositionFromTop(lastPos, 0, duration);
}

@Override
Expand Down Expand Up @@ -406,9 +371,8 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
@Override
public void setNumColumns(int numColumns) {
super.setNumColumns(numColumns);
mNumColumns = numColumns;
ListAdapter adapter = getAdapter();
if (adapter != null && adapter instanceof HeaderViewGridAdapter) {
if (adapter instanceof HeaderViewGridAdapter) {
((HeaderViewGridAdapter) adapter).setNumColumns(numColumns);
}
}
Expand All @@ -426,7 +390,7 @@ private static class HeaderViewGridAdapter implements WrapperListAdapter, Filter
private final DataSetObservable mDataSetObservable = new DataSetObservable();
private final ListAdapter mAdapter;
static final ArrayList<FixedViewInfo> EMPTY_INFO_LIST =
new ArrayList<FixedViewInfo>();
new ArrayList<>();

// This ArrayList is assumed to NOT be null.
ArrayList<FixedViewInfo> mHeaderViewInfos;
Expand Down Expand Up @@ -458,7 +422,7 @@ public HeaderViewGridAdapter(ArrayList<FixedViewInfo> headerViewInfos, ArrayList
&& areAllListInfosSelectable(mFooterViewInfos);
}

public void setNumColumns(int numColumns) {
void setNumColumns(int numColumns) {
if (numColumns < 1) {
return;
}
Expand All @@ -468,15 +432,15 @@ public void setNumColumns(int numColumns) {
}
}

public void setRowHeight(int height) {
void setRowHeight(int height) {
mRowHeight = height;
}

public int getHeadersCount() {
return mHeaderViewInfos.size();
}

public int getFootersCount() {
int getFootersCount() {
return mFooterViewInfos.size();
}

Expand All @@ -496,7 +460,7 @@ private boolean areAllListInfosSelectable(ArrayList<FixedViewInfo> infos) {
return true;
}

public boolean removeHeader(View v) {
boolean removeHeader(View v) {
for (int i = 0; i < mHeaderViewInfos.size(); i++) {
FixedViewInfo info = mHeaderViewInfos.get(i);
if (info.view == v) {
Expand All @@ -510,7 +474,7 @@ public boolean removeHeader(View v) {
return false;
}

public boolean removeFooter(View v) {
boolean removeFooter(View v) {
for (int i = 0; i < mFooterViewInfos.size(); i++) {
FixedViewInfo info = mFooterViewInfos.get(i);
if (info.view == v) {
Expand Down Expand Up @@ -543,8 +507,7 @@ public boolean areAllItemsEnabled() {
}

private int getAdapterAndPlaceHolderCount() {
final int adapterCount = (int) (Math.ceil(1f * mAdapter.getCount() / mNumColumns) * mNumColumns);
return adapterCount;
return (int) (Math.ceil(1f * mAdapter.getCount() / mNumColumns) * mNumColumns);
}

@Override
Expand Down Expand Up @@ -657,8 +620,7 @@ public View getView(int position, View convertView, ViewGroup parent) {
adapterCount = getAdapterAndPlaceHolderCount();
if (adjPosition < adapterCount) {
if (adjPosition < mAdapter.getCount()) {
View view = mAdapter.getView(adjPosition, convertView, parent);
return view;
return mAdapter.getView(adjPosition, convertView, parent);
} else {
if (convertView == null) {
convertView = new View(parent.getContext());
Expand Down
4 changes: 2 additions & 2 deletions owncloudApp/src/main/res/menu/file_actions_menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
<item
android:id="@+id/file_action_select_all"
android:title="@string/actionbar_select_all"
android:showAsAction="never" />
app:showAsAction="never" />

<item
android:id="@+id/action_select_inverse"
android:title="@string/actionbar_select_inverse"
android:visible="true"
android:showAsAction="never" />
app:showAsAction="never" />

<item
android:id="@+id/action_share_file"
Expand Down