Custom folder RV item

Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
Mario Danic 2017-05-04 16:54:52 +02:00 committed by AndyScherzinger
parent 662b08a12c
commit 14c2d13c81
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B
4 changed files with 127 additions and 99 deletions

View file

@ -985,7 +985,7 @@ public class FileContentProvider extends ContentProvider {
// add type column default being IMAGE(0) // add type column default being IMAGE(0)
db.execSQL(ALTER_TABLE + ProviderTableMeta.SYNCED_FOLDERS_TABLE_NAME + db.execSQL(ALTER_TABLE + ProviderTableMeta.SYNCED_FOLDERS_TABLE_NAME +
ADD_COLUMN + ProviderTableMeta.SYNCED_FOLDER_TYPE + ADD_COLUMN + ProviderTableMeta.SYNCED_FOLDER_TYPE +
" INTEGER " + " DEFAULT 0"); " INTEGER " + " DEFAULT 3");
upgraded = true; upgraded = true;
db.setTransactionSuccessful(); db.setTransactionSuccessful();
@ -1178,6 +1178,7 @@ public class FileContentProvider extends ContentProvider {
+ ProviderTableMeta.SYNCED_FOLDER_ENABLED + " INTEGER, " // enabled + ProviderTableMeta.SYNCED_FOLDER_ENABLED + " INTEGER, " // enabled
+ ProviderTableMeta.SYNCED_FOLDER_SUBFOLDER_BY_DATE + " INTEGER, " // subfolder by date + ProviderTableMeta.SYNCED_FOLDER_SUBFOLDER_BY_DATE + " INTEGER, " // subfolder by date
+ ProviderTableMeta.SYNCED_FOLDER_ACCOUNT + " TEXT, " // account + ProviderTableMeta.SYNCED_FOLDER_ACCOUNT + " TEXT, " // account
+ ProviderTableMeta.SYNCED_FOLDER_TYPE + " INTEGER, " // type
+ ProviderTableMeta.SYNCED_FOLDER_UPLOAD_ACTION + " INTEGER );" // upload action + ProviderTableMeta.SYNCED_FOLDER_UPLOAD_ACTION + " INTEGER );" // upload action
); );
} }

View file

@ -29,6 +29,7 @@ import android.view.ViewGroup;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
import com.afollestad.sectionedrecyclerview.SectionedRecyclerViewAdapter; import com.afollestad.sectionedrecyclerview.SectionedRecyclerViewAdapter;
@ -61,6 +62,8 @@ public class FolderSyncAdapter extends SectionedRecyclerViewAdapter<FolderSyncAd
mListener = listener; mListener = listener;
mSyncFolderItems = new ArrayList<>(); mSyncFolderItems = new ArrayList<>();
mLight = light; mLight = light;
shouldShowHeadersForEmptySections(true);
} }
public void setSyncFolderItems(List<SyncedFolderDisplayItem> syncFolderItems) { public void setSyncFolderItems(List<SyncedFolderDisplayItem> syncFolderItems) {
@ -81,6 +84,10 @@ public class FolderSyncAdapter extends SectionedRecyclerViewAdapter<FolderSyncAd
@Override @Override
public int getItemCount(int section) { public int getItemCount(int section) {
if (section == 0) {
return 0;
}
if (mSyncFolderItems.get(section).getFilePaths() != null) { if (mSyncFolderItems.get(section).getFilePaths() != null) {
return mSyncFolderItems.get(section).getFilePaths().size(); return mSyncFolderItems.get(section).getFilePaths().size();
} else { } else {
@ -90,17 +97,33 @@ public class FolderSyncAdapter extends SectionedRecyclerViewAdapter<FolderSyncAd
@Override @Override
public void onBindHeaderViewHolder(final MainViewHolder holder, final int section) { public void onBindHeaderViewHolder(final MainViewHolder holder, final int section) {
holder.title.setText(mSyncFolderItems.get(section).getFolderName()); if (section != 0) {
holder.mainHeaderContainer.setVisibility(View.VISIBLE);
holder.customFolderHeaderContainer.setVisibility(View.GONE);
if (MediaFolder.VIDEO == mSyncFolderItems.get(section).getType()) { holder.title.setText(mSyncFolderItems.get(section).getFolderName());
holder.type.setImageResource(R.drawable.ic_video_18dp);
} else if (MediaFolder.IMAGE == mSyncFolderItems.get(section).getType()) { if (MediaFolder.VIDEO == mSyncFolderItems.get(section).getType()) {
holder.type.setImageResource(R.drawable.ic_image_18dp); holder.type.setImageResource(R.drawable.ic_video_18dp);
} else { } else if (MediaFolder.IMAGE == mSyncFolderItems.get(section).getType()) {
holder.type.setImageResource(R.drawable.ic_folder_star_18dp); holder.type.setImageResource(R.drawable.ic_image_18dp);
} } else {
holder.type.setImageResource(R.drawable.ic_folder_star_18dp);
holder.syncStatusButton.setVisibility(View.VISIBLE); }
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());
holder.syncStatusButton.setVisibility(View.VISIBLE);
holder.syncStatusButton.setTag(section); holder.syncStatusButton.setTag(section);
holder.syncStatusButton.setOnClickListener(new View.OnClickListener() { holder.syncStatusButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -124,12 +147,17 @@ public class FolderSyncAdapter extends SectionedRecyclerViewAdapter<FolderSyncAd
} }
}); });
} }
} else {
holder.mainHeaderContainer.setVisibility(View.GONE);
holder.customFolderHeaderContainer.setVisibility(View.VISIBLE);
}
} }
@Override @Override
public void onBindViewHolder(MainViewHolder holder, int section, int relativePosition, int absolutePosition) { 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)); File file = new File(mSyncFolderItems.get(section).getFilePaths().get(relativePosition));
ThumbnailsCacheManager.MediaThumbnailGenerationTask task = ThumbnailsCacheManager.MediaThumbnailGenerationTask task =
@ -159,7 +187,7 @@ public class FolderSyncAdapter extends SectionedRecyclerViewAdapter<FolderSyncAd
holder.thumbnailDarkener.setVisibility(View.GONE); 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); //holder.itemView.setOnClickListener(this);
} else { } else {
holder.itemView.setTag(relativePosition % mGridWidth); holder.itemView.setTag(relativePosition % mGridWidth);
@ -192,8 +220,13 @@ public class FolderSyncAdapter extends SectionedRecyclerViewAdapter<FolderSyncAd
private final TextView counterValue; private final TextView counterValue;
private final ImageView thumbnailDarkener; private final ImageView thumbnailDarkener;
private final RelativeLayout mainHeaderContainer;
private final RelativeLayout customFolderHeaderContainer;
private MainViewHolder(View itemView) { private MainViewHolder(View itemView) {
super(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); image = (ImageView) itemView.findViewById(R.id.thumbnail);
title = (TextView) itemView.findViewById(R.id.title); title = (TextView) itemView.findViewById(R.id.title);
type = (ImageView) itemView.findViewById(R.id.type); type = (ImageView) itemView.findViewById(R.id.type);

View file

@ -20,74 +20,95 @@
--> -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content">
android:paddingTop="@dimen/alternate_half_padding"
android:paddingBottom="@dimen/alternate_half_padding"
android:paddingLeft="@dimen/standard_padding">
<LinearLayout <RelativeLayout
android:id="@+id/title_container" android:id="@+id/header_container"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignBottom="@+id/buttonBar" android:paddingBottom="@dimen/alternate_half_padding"
android:layout_alignParentLeft="true" android:paddingLeft="@dimen/standard_padding"
android:layout_alignTop="@+id/buttonBar" android:paddingTop="@dimen/alternate_half_padding">
android:layout_toLeftOf="@+id/buttonBar"
android:ellipsize="middle" <LinearLayout
android:gravity="start|center_vertical" android:id="@+id/title_container"
android:text="@string/placeholder_filename" android:layout_width="wrap_content"
android:textColor="?android:textColorPrimary" android:layout_height="wrap_content"
android:textStyle="bold"/> android:layout_alignBottom="@+id/buttonBar"
android:layout_alignParentLeft="true"
android:layout_alignTop="@+id/buttonBar"
android:layout_toLeftOf="@+id/buttonBar">
<ImageView
android:id="@+id/type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start|center_vertical"
android:paddingRight="@dimen/standard_half_padding"
android:src="@drawable/ic_account_plus"/>
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start|center_vertical"
android:ellipsize="middle"
android:text="Header Text"
android:textColor="?android:textColorPrimary"
android:textStyle="bold"/>
</LinearLayout>
<LinearLayout
android:id="@+id/buttonBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true">
<ImageButton
android:id="@+id/syncStatusButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/transparent"
android:clickable="true"
android:padding="@dimen/standard_half_padding"
android:src="@drawable/ic_cloud_sync_off"/>
<ImageButton
android:id="@+id/settingsButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/transparent"
android:clickable="true"
android:paddingBottom="@dimen/standard_half_padding"
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 <ImageView
android:id="@+id/type" android:id="@+id/imageView"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="start|center_vertical" android:layout_centerVertical="true"
android:paddingRight="@dimen/standard_half_padding" android:layout_toLeftOf="@+id/custom_folder_tv"
android:src="@drawable/ic_account_plus"/> android:paddingRight="4dp"
android:src="@drawable/ic_folder_star_24dp"/>
<TextView <TextView
android:id="@+id/title" android:id="@+id/custom_folder_tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start|center_vertical"
android:ellipsize="middle"
android:text="Header Text"
android:textColor="?android:textColorPrimary"
android:textStyle="bold"/>
</LinearLayout>
<LinearLayout
android:id="@+id/buttonBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true">
<ImageButton
android:id="@+id/syncStatusButton"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@color/transparent" android:layout_centerInParent="true"
android:clickable="true" android:text="@string/autoupload_custom_folder"/>
android:paddingTop="@dimen/standard_half_padding" </RelativeLayout>
android:paddingBottom="@dimen/standard_half_padding"
android:paddingLeft="@dimen/standard_half_padding"
android:paddingRight="@dimen/standard_padding"
android:src="@drawable/ic_cloud_sync_off"/>
<ImageButton
android:id="@+id/settingsButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/transparent"
android:clickable="true"
android:paddingBottom="@dimen/standard_half_padding"
android:paddingLeft="0dp"
android:paddingRight="@dimen/standard_padding"
android:paddingTop="@dimen/standard_half_padding"
android:src="@drawable/ic_dots_vertical"/>
</LinearLayout>
</RelativeLayout> </RelativeLayout>

View file

@ -35,33 +35,6 @@
<include <include
layout="@layout/toolbar_standard"/> 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 <FrameLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"