소스 검색

add icons to the grid headers depending on the type

AndyScherzinger 8 년 전
부모
커밋
3147a2c86a

+ 6 - 4
src/main/java/com/owncloud/android/datamodel/MediaFolder.java

@@ -27,9 +27,11 @@ import java.util.List;
  * Business object representing a media folder with all information that are gathered via media queries.
  */
 public class MediaFolder {
-    public enum FOLDER_TYPE {
-        AUDIO, VIDEO, IMAGE, IMAGE_VIDEO, CUSTOM
-    }
+    public static final int AUDIO = 3;
+    public static final int VIDEO = 1;
+    public static final int IMAGE = 2;
+    public static final int IMAGE_VIDEO = 3;
+    public static final int CUSTOM = 4;
 
     /** name of the folder. */
     public String folderName;
@@ -43,5 +45,5 @@ public class MediaFolder {
     /** total number of files in the media folder. */
     public long numberOfFiles;
 
-    public FOLDER_TYPE type;
+    public int type;
 }

+ 2 - 2
src/main/java/com/owncloud/android/datamodel/MediaProvider.java

@@ -112,7 +112,7 @@ public class MediaProvider {
                 MediaFolder mediaFolder = new MediaFolder();
                 folderName = cursorFolders.getString(cursorFolders.getColumnIndex(
                         MediaStore.Images.Media.BUCKET_DISPLAY_NAME));
-                mediaFolder.type = MediaFolder.FOLDER_TYPE.IMAGE;
+                mediaFolder.type = MediaFolder.IMAGE;
                 mediaFolder.folderName = folderName;
                 mediaFolder.filePaths = new ArrayList<>();
 
@@ -181,7 +181,7 @@ public class MediaProvider {
                 MediaFolder mediaFolder = new MediaFolder();
                 folderName = cursorFolders.getString(cursorFolders.getColumnIndex(
                         MediaStore.Video.Media.BUCKET_DISPLAY_NAME));
-                mediaFolder.type = MediaFolder.FOLDER_TYPE.VIDEO;
+                mediaFolder.type = MediaFolder.VIDEO;
                 mediaFolder.folderName = folderName;
                 mediaFolder.filePaths = new ArrayList<>();
 

+ 12 - 2
src/main/java/com/owncloud/android/datamodel/SyncedFolderDisplayItem.java

@@ -31,6 +31,7 @@ public class SyncedFolderDisplayItem extends SyncedFolder {
     private List<String> filePaths;
     private String folderName;
     private long numberOfFiles;
+    private int type;
 
     /**
      * constructor for the display item specialization for a synced folder object.
@@ -47,14 +48,16 @@ public class SyncedFolderDisplayItem extends SyncedFolder {
      * @param filePaths       the UI info for the file path
      * @param folderName      the UI info for the folder's name
      * @param numberOfFiles   the UI info for number of files within the folder
+     * @param type            the type of the folder
      */
     public SyncedFolderDisplayItem(long id, String localPath, String remotePath, Boolean wifiOnly, Boolean chargingOnly,
                                    Boolean subfolderByDate, String account, Integer uploadAction, Boolean enabled,
-                                   List<String> filePaths, String folderName, long numberOfFiles) {
+                                   List<String> filePaths, String folderName, long numberOfFiles, int type) {
         super(id, localPath, remotePath, wifiOnly, chargingOnly, subfolderByDate, account, uploadAction, enabled);
         this.filePaths = filePaths;
         this.folderName = folderName;
         this.numberOfFiles = numberOfFiles;
+        this.type = type;
     }
 
     public SyncedFolderDisplayItem(long id, String localPath, String remotePath, Boolean wifiOnly, Boolean chargingOnly,
@@ -64,7 +67,6 @@ public class SyncedFolderDisplayItem extends SyncedFolder {
         this.folderName = folderName;
     }
 
-
     public List<String> getFilePaths() {
         return filePaths;
     }
@@ -88,4 +90,12 @@ public class SyncedFolderDisplayItem extends SyncedFolder {
     public void setNumberOfFiles(long numberOfFiles) {
         this.numberOfFiles = numberOfFiles;
     }
+
+    public int getType() {
+        return type;
+    }
+
+    public void setType(int type) {
+        this.type = type;
+    }
 }

+ 4 - 2
src/main/java/com/owncloud/android/ui/activity/FolderSyncActivity.java

@@ -318,7 +318,8 @@ public class FolderSyncActivity extends FileActivity implements FolderSyncAdapte
                 syncedFolder.isEnabled(),
                 mediaFolder.filePaths,
                 mediaFolder.folderName,
-                mediaFolder.numberOfFiles);
+                mediaFolder.numberOfFiles,
+                mediaFolder.type);
     }
 
     /**
@@ -341,7 +342,8 @@ public class FolderSyncActivity extends FileActivity implements FolderSyncAdapte
                 false,
                 mediaFolder.filePaths,
                 mediaFolder.folderName,
-                mediaFolder.numberOfFiles);
+                mediaFolder.numberOfFiles,
+                mediaFolder.type);
     }
 
     /**

+ 8 - 0
src/main/java/com/owncloud/android/ui/adapter/FolderSyncAdapter.java

@@ -33,6 +33,7 @@ import android.widget.TextView;
 
 import com.afollestad.sectionedrecyclerview.SectionedRecyclerViewAdapter;
 import com.owncloud.android.R;
+import com.owncloud.android.datamodel.MediaFolder;
 import com.owncloud.android.datamodel.SyncedFolderDisplayItem;
 import com.owncloud.android.datamodel.ThumbnailsCacheManager;
 import com.owncloud.android.utils.ThemeUtils;
@@ -90,6 +91,11 @@ public class FolderSyncAdapter extends SectionedRecyclerViewAdapter<FolderSyncAd
     @Override
     public void onBindHeaderViewHolder(final MainViewHolder holder, final int section) {
         holder.title.setText(mSyncFolderItems.get(section).getFolderName());
+        if (MediaFolder.VIDEO == mSyncFolderItems.get(section).getType()) {
+            holder.type.setImageResource(R.drawable.ic_video_18dp);
+        } else {
+            holder.type.setImageResource(R.drawable.ic_image_18dp);
+        }
         holder.syncStatusButton.setVisibility(View.VISIBLE);
         holder.syncStatusButton.setTag(section);
         holder.syncStatusButton.setOnClickListener(new View.OnClickListener() {
@@ -175,6 +181,7 @@ public class FolderSyncAdapter extends SectionedRecyclerViewAdapter<FolderSyncAd
     static class MainViewHolder extends RecyclerView.ViewHolder {
         private final ImageView image;
         private final TextView title;
+        private final ImageView type;
         private final ImageButton menuButton;
         private final ImageButton syncStatusButton;
         private final LinearLayout counterBar;
@@ -185,6 +192,7 @@ public class FolderSyncAdapter extends SectionedRecyclerViewAdapter<FolderSyncAd
             super(itemView);
             image = (ImageView) itemView.findViewById(R.id.thumbnail);
             title = (TextView) itemView.findViewById(R.id.title);
+            type = (ImageView) itemView.findViewById(R.id.type);
             menuButton = (ImageButton) itemView.findViewById(R.id.settingsButton);
             syncStatusButton = (ImageButton) itemView.findViewById(R.id.syncStatusButton);
             counterBar = (LinearLayout) itemView.findViewById(R.id.counterLayout);

BIN
src/main/res/drawable-hdpi/ic_image_18dp.png


BIN
src/main/res/drawable-hdpi/ic_video_18dp.png


BIN
src/main/res/drawable-mdpi/ic_image_18dp.png


BIN
src/main/res/drawable-mdpi/ic_video_18dp.png


BIN
src/main/res/drawable-xhdpi/ic_image_18dp.png


BIN
src/main/res/drawable-xhdpi/ic_video_18dp.png


BIN
src/main/res/drawable-xxhdpi/ic_image_18dp.png


BIN
src/main/res/drawable-xxhdpi/ic_video_18dp.png


BIN
src/main/res/drawable-xxxhdpi/ic_image_18dp.png


BIN
src/main/res/drawable-xxxhdpi/ic_video_18dp.png


+ 22 - 2
src/main/res/layout/folder_sync_item_header.xml

@@ -25,8 +25,8 @@
                 android:paddingBottom="@dimen/alternate_half_padding"
                 android:paddingLeft="@dimen/standard_padding">
 
-    <TextView
-        android:id="@+id/title"
+    <LinearLayout
+        android:id="@+id/title_container"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_alignBottom="@+id/buttonBar"
@@ -39,6 +39,26 @@
         android:textColor="?android:textColorPrimary"
         android:textStyle="bold"/>
 
+        <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"