mirror of
https://github.com/nextcloud/android.git
synced 2024-11-27 09:39:25 +03:00
Custom folder RV item
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
662b08a12c
commit
14c2d13c81
4 changed files with 127 additions and 99 deletions
|
@ -985,7 +985,7 @@ public class FileContentProvider extends ContentProvider {
|
|||
// add type column default being IMAGE(0)
|
||||
db.execSQL(ALTER_TABLE + ProviderTableMeta.SYNCED_FOLDERS_TABLE_NAME +
|
||||
ADD_COLUMN + ProviderTableMeta.SYNCED_FOLDER_TYPE +
|
||||
" INTEGER " + " DEFAULT 0");
|
||||
" INTEGER " + " DEFAULT 3");
|
||||
|
||||
upgraded = true;
|
||||
db.setTransactionSuccessful();
|
||||
|
@ -1178,6 +1178,7 @@ public class FileContentProvider extends ContentProvider {
|
|||
+ ProviderTableMeta.SYNCED_FOLDER_ENABLED + " INTEGER, " // enabled
|
||||
+ ProviderTableMeta.SYNCED_FOLDER_SUBFOLDER_BY_DATE + " INTEGER, " // subfolder by date
|
||||
+ ProviderTableMeta.SYNCED_FOLDER_ACCOUNT + " TEXT, " // account
|
||||
+ ProviderTableMeta.SYNCED_FOLDER_TYPE + " INTEGER, " // type
|
||||
+ ProviderTableMeta.SYNCED_FOLDER_UPLOAD_ACTION + " INTEGER );" // upload action
|
||||
);
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import android.view.ViewGroup;
|
|||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.afollestad.sectionedrecyclerview.SectionedRecyclerViewAdapter;
|
||||
|
@ -61,6 +62,8 @@ public class FolderSyncAdapter extends SectionedRecyclerViewAdapter<FolderSyncAd
|
|||
mListener = listener;
|
||||
mSyncFolderItems = new ArrayList<>();
|
||||
mLight = light;
|
||||
|
||||
shouldShowHeadersForEmptySections(true);
|
||||
}
|
||||
|
||||
public void setSyncFolderItems(List<SyncedFolderDisplayItem> syncFolderItems) {
|
||||
|
@ -81,6 +84,10 @@ public class FolderSyncAdapter extends SectionedRecyclerViewAdapter<FolderSyncAd
|
|||
|
||||
@Override
|
||||
public int getItemCount(int section) {
|
||||
if (section == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (mSyncFolderItems.get(section).getFilePaths() != null) {
|
||||
return mSyncFolderItems.get(section).getFilePaths().size();
|
||||
} else {
|
||||
|
@ -90,6 +97,10 @@ public class FolderSyncAdapter extends SectionedRecyclerViewAdapter<FolderSyncAd
|
|||
|
||||
@Override
|
||||
public void onBindHeaderViewHolder(final MainViewHolder holder, final int section) {
|
||||
if (section != 0) {
|
||||
holder.mainHeaderContainer.setVisibility(View.VISIBLE);
|
||||
holder.customFolderHeaderContainer.setVisibility(View.GONE);
|
||||
|
||||
holder.title.setText(mSyncFolderItems.get(section).getFolderName());
|
||||
|
||||
if (MediaFolder.VIDEO == mSyncFolderItems.get(section).getType()) {
|
||||
|
@ -110,6 +121,18 @@ public class FolderSyncAdapter extends SectionedRecyclerViewAdapter<FolderSyncAd
|
|||
mListener.onSyncStatusToggleClick(section, mSyncFolderItems.get(section));
|
||||
}
|
||||
});
|
||||
setSyncButtonActiveIcon(holder.syncStatusButton, mSyncFolderItems.get(section).isEnabled());
|
||||
|
||||
holder.syncStatusButton.setVisibility(View.VISIBLE);
|
||||
holder.syncStatusButton.setTag(section);
|
||||
holder.syncStatusButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mSyncFolderItems.get(section).setEnabled(!mSyncFolderItems.get(section).isEnabled());
|
||||
setSyncButtonActiveIcon(holder.syncStatusButton, mSyncFolderItems.get(section).isEnabled());
|
||||
mListener.onSyncStatusToggleClick(section, mSyncFolderItems.get(section));
|
||||
}
|
||||
});
|
||||
setSyncButtonActiveIcon(holder.syncStatusButton, mSyncFolderItems.get(section).isEnabled());
|
||||
|
||||
if (mLight) {
|
||||
|
@ -124,12 +147,17 @@ public class FolderSyncAdapter extends SectionedRecyclerViewAdapter<FolderSyncAd
|
|||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
holder.mainHeaderContainer.setVisibility(View.GONE);
|
||||
holder.customFolderHeaderContainer.setVisibility(View.VISIBLE);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(MainViewHolder holder, int section, int relativePosition, int absolutePosition) {
|
||||
|
||||
if (mSyncFolderItems.get(section).getFilePaths() != null) {
|
||||
if (section != 0 && mSyncFolderItems.get(section - 1).getFilePaths() != null) {
|
||||
File file = new File(mSyncFolderItems.get(section).getFilePaths().get(relativePosition));
|
||||
|
||||
ThumbnailsCacheManager.MediaThumbnailGenerationTask task =
|
||||
|
@ -159,7 +187,7 @@ public class FolderSyncAdapter extends SectionedRecyclerViewAdapter<FolderSyncAd
|
|||
holder.thumbnailDarkener.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
//holder.itemView.setTag(String.format(Locale.getDefault(), "%d:%d:%d", section, relativePos, absolutePos));
|
||||
//holder.itemView.setTag(String.format(Locale.getDefault(), "%d:%d:%d", adjustedSection, relativePos, absolutePos));
|
||||
//holder.itemView.setOnClickListener(this);
|
||||
} else {
|
||||
holder.itemView.setTag(relativePosition % mGridWidth);
|
||||
|
@ -192,8 +220,13 @@ public class FolderSyncAdapter extends SectionedRecyclerViewAdapter<FolderSyncAd
|
|||
private final TextView counterValue;
|
||||
private final ImageView thumbnailDarkener;
|
||||
|
||||
private final RelativeLayout mainHeaderContainer;
|
||||
private final RelativeLayout customFolderHeaderContainer;
|
||||
|
||||
private MainViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
mainHeaderContainer = (RelativeLayout) itemView.findViewById(R.id.header_container);
|
||||
customFolderHeaderContainer = (RelativeLayout) itemView.findViewById(R.id.custom_folder);
|
||||
image = (ImageView) itemView.findViewById(R.id.thumbnail);
|
||||
title = (TextView) itemView.findViewById(R.id.title);
|
||||
type = (ImageView) itemView.findViewById(R.id.type);
|
||||
|
|
|
@ -19,11 +19,16 @@
|
|||
License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/header_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="@dimen/alternate_half_padding"
|
||||
android:paddingBottom="@dimen/alternate_half_padding"
|
||||
android:paddingLeft="@dimen/standard_padding">
|
||||
android:paddingLeft="@dimen/standard_padding"
|
||||
android:paddingTop="@dimen/alternate_half_padding">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/title_container"
|
||||
|
@ -32,12 +37,7 @@
|
|||
android:layout_alignBottom="@+id/buttonBar"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignTop="@+id/buttonBar"
|
||||
android:layout_toLeftOf="@+id/buttonBar"
|
||||
android:ellipsize="middle"
|
||||
android:gravity="start|center_vertical"
|
||||
android:text="@string/placeholder_filename"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textStyle="bold"/>
|
||||
android:layout_toLeftOf="@+id/buttonBar">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/type"
|
||||
|
@ -71,10 +71,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:background="@color/transparent"
|
||||
android:clickable="true"
|
||||
android:paddingTop="@dimen/standard_half_padding"
|
||||
android:paddingBottom="@dimen/standard_half_padding"
|
||||
android:paddingLeft="@dimen/standard_half_padding"
|
||||
android:paddingRight="@dimen/standard_padding"
|
||||
android:padding="@dimen/standard_half_padding"
|
||||
android:src="@drawable/ic_cloud_sync_off"/>
|
||||
|
||||
<ImageButton
|
||||
|
@ -84,10 +81,34 @@
|
|||
android:background="@color/transparent"
|
||||
android:clickable="true"
|
||||
android:paddingBottom="@dimen/standard_half_padding"
|
||||
android:paddingLeft="0dp"
|
||||
android:paddingLeft="@dimen/standard_half_padding"
|
||||
android:paddingRight="@dimen/standard_padding"
|
||||
android:paddingTop="@dimen/standard_half_padding"
|
||||
android:src="@drawable/ic_dots_vertical"/>
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/custom_folder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="48dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toLeftOf="@+id/custom_folder_tv"
|
||||
android:paddingRight="4dp"
|
||||
android:src="@drawable/ic_folder_star_24dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/custom_folder_tv"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:text="@string/autoupload_custom_folder"/>
|
||||
</RelativeLayout>
|
||||
|
||||
</RelativeLayout>
|
|
@ -35,33 +35,6 @@
|
|||
<include
|
||||
layout="@layout/toolbar_standard"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/custom_folder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/listItemHighlighted"
|
||||
android:gravity="center"
|
||||
android:layout_below="@+id/appbar">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="@dimen/standard_padding"
|
||||
android:paddingLeft="@dimen/standard_padding"
|
||||
android:paddingRight="@dimen/standard_half_padding"
|
||||
android:paddingTop="@dimen/standard_padding"
|
||||
android:src="@drawable/ic_folder_star_24dp"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="@dimen/standard_padding"
|
||||
android:paddingRight="@dimen/standard_padding"
|
||||
android:paddingTop="@dimen/standard_padding"
|
||||
android:text="Create custom folder"/>
|
||||
</LinearLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
|
Loading…
Reference in a new issue