Browse Source

minor renamings & javadoc

AndyScherzinger 8 years ago
parent
commit
c30dcd4a6d

+ 3 - 5
src/com/owncloud/android/datamodel/MediaProvider.java

@@ -31,7 +31,7 @@ import java.util.ArrayList;
 import java.util.List;
 
 /**
- * media queries to gain access to media lists for the device.
+ * Media queries to gain access to media lists for the device.
  */
 public class MediaProvider {
     private static final String TAG = MediaProvider.class.getSimpleName();
@@ -44,15 +44,13 @@ public class MediaProvider {
      * @param contentResolver the content resolver
      * @return List with images folders
      */
-    public static List<MediaFolder> getAllShownImagesPath(ContentResolver contentResolver) {
+    public static List<MediaFolder> getMediaFolders(ContentResolver contentResolver) {
         Cursor cursor;
         List<MediaFolder> mediaFolders = new ArrayList<>();
         int column_index_data, column_index_folder_name, column_index_data_image;
-        ArrayList<String> listOfAllImages = new ArrayList<>();
         String absolutePathOfImage;
         String folderName;
 
-        String[] projectionTest = {MediaStore.MediaColumns.DATA, MediaStore.Images.Media.BUCKET_DISPLAY_NAME, MediaStore.Images.Media.DATE_TAKEN};
         String[] folderProjection = new String[]{"Distinct " + MediaStore.Images.Media.BUCKET_DISPLAY_NAME, MediaStore
                 .MediaColumns.DATA, MediaStore.Images.Media.DATE_TAKEN};
         String[] fileProjection = new String[]{MediaStore.MediaColumns.DATA};
@@ -91,7 +89,7 @@ public class MediaProvider {
                 mediaFolder.filePaths = new ArrayList<>();
 
                 column_index_data_image = cursorImages.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA);
-                Log.d(TAG, "Reading images for --> " + mediaFolder.absolutePath);
+                Log.d(TAG, "Reading images for " + mediaFolder.absolutePath);
                 while (cursorImages.moveToNext()) {
                     mediaFolder.filePaths.add(cursorImages.getString(column_index_data_image));
                 }

+ 22 - 5
src/com/owncloud/android/datamodel/SyncedFolderItem.java → src/com/owncloud/android/datamodel/SyncedFolderDisplayItem.java

@@ -24,16 +24,33 @@ package com.owncloud.android.datamodel;
 import java.util.List;
 
 /**
- * TODO javadoc
+ * Display item specialization for synced folder objects to be displayed in a list/grid view adding further
+ * information to be displayed in the UI but not part of the persisted underlying {@link SyncedFolder} object.
  */
-public class SyncedFolderItem extends SyncedFolder {
+public class SyncedFolderDisplayItem extends SyncedFolder {
     private List<String> filePaths;
     private String folderName;
     private long numberOfFiles;
 
-    public SyncedFolderItem(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) {
+    /**
+     * constructor for the display item specialization for a synced folder object.
+     *
+     * @param id              id
+     * @param localPath       local path
+     * @param remotePath      remote path
+     * @param wifiOnly        upload on wifi only flag
+     * @param chargingOnly    upload on charging only
+     * @param subfolderByDate create sub-folders by date (month)
+     * @param account         the account owning the synced folder
+     * @param uploadAction    the action to be done after the upload
+     * @param enabled         flag if synced folder config is active
+     * @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
+     */
+    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) {
         super(id, localPath, remotePath, wifiOnly, chargingOnly, subfolderByDate, account, uploadAction, enabled);
         this.filePaths = filePaths;
         this.folderName = folderName;

+ 44 - 49
src/com/owncloud/android/ui/activity/FolderSyncActivity.java

@@ -41,7 +41,7 @@ import com.owncloud.android.datamodel.MediaFolder;
 import com.owncloud.android.datamodel.MediaProvider;
 import com.owncloud.android.datamodel.OCFile;
 import com.owncloud.android.datamodel.SyncedFolder;
-import com.owncloud.android.datamodel.SyncedFolderItem;
+import com.owncloud.android.datamodel.SyncedFolderDisplayItem;
 import com.owncloud.android.datamodel.SyncedFolderProvider;
 import com.owncloud.android.ui.adapter.FolderSyncAdapter;
 import com.owncloud.android.ui.decoration.MediaGridItemDecoration;
@@ -56,7 +56,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.TimerTask;
 
-import static com.owncloud.android.datamodel.SyncedFolderItem.UNPERSISTED_ID;
+import static com.owncloud.android.datamodel.SyncedFolderDisplayItem.UNPERSISTED_ID;
 
 /**
  * Activity displaying all auto-synced folders and/or instant upload media folders.
@@ -73,7 +73,7 @@ public class FolderSyncActivity extends FileActivity implements FolderSyncAdapte
     private LinearLayout mProgress;
     private TextView mEmpty;
     private SyncedFolderProvider mSyncedFolderProvider;
-    private List<SyncedFolderItem> syncFolderItems;
+    private List<SyncedFolderDisplayItem> syncFolderItems;
     private SyncedFolderPreferencesDialogFragment mSyncedFolderPreferencesDialogFragment;
 
     @Override
@@ -126,17 +126,10 @@ public class FolderSyncActivity extends FileActivity implements FolderSyncAdapte
         new Thread(new Runnable() {
             @Override
             public void run() {
-                final List<MediaFolder> mediaFolders = MediaProvider.getAllShownImagesPath(getContentResolver());
-                syncFolderItems = sortSyncedFolderItem(mergeFolderData(mSyncedFolderProvider.getSyncedFolders(),
+                final List<MediaFolder> mediaFolders = MediaProvider.getMediaFolders(getContentResolver());
+                syncFolderItems = sortSyncedFolderItems(mergeFolderData(mSyncedFolderProvider.getSyncedFolders(),
                         mediaFolders));
 
-                // TODO remove before merging to master, keeping it for debugging atm
-                /**
-                 for (MediaFolder mediaFolder : mediaFolders) {
-                 Log.d(TAG, mediaFolder.absolutePath);
-                 }
-                 */
-
                 mHandler.post(new TimerTask() {
                     @Override
                     public void run() {
@@ -149,17 +142,17 @@ public class FolderSyncActivity extends FileActivity implements FolderSyncAdapte
     }
 
     /**
-     * merges two lists of SyncedFolder and MediaFolder items into one of SyncedFolderItems.
+     * merges two lists of {@link SyncedFolder} and {@link MediaFolder} items into one of SyncedFolderItems.
      *
      * @param syncedFolders the synced folders
      * @param mediaFolders  the media folders
      * @return the merged list of SyncedFolderItems
      */
     @NonNull
-    private List<SyncedFolderItem> mergeFolderData(List<SyncedFolder> syncedFolders,
-                                                   @NonNull List<MediaFolder> mediaFolders) {
+    private List<SyncedFolderDisplayItem> mergeFolderData(List<SyncedFolder> syncedFolders,
+                                                          @NonNull List<MediaFolder> mediaFolders) {
         Map<String, SyncedFolder> syncedFoldersMap = createSyncedFoldersMap(syncedFolders);
-        List<SyncedFolderItem> result = new ArrayList<>();
+        List<SyncedFolderDisplayItem> result = new ArrayList<>();
 
         for (MediaFolder mediaFolder : mediaFolders) {
             if (syncedFoldersMap.containsKey(mediaFolder.absolutePath)) {
@@ -174,13 +167,15 @@ public class FolderSyncActivity extends FileActivity implements FolderSyncAdapte
     }
 
     /**
-     * Sorts list by SyncedFolderItems.
+     * Sorts list of {@link SyncedFolderDisplayItem}s.
      *
-     * @param syncFolderItemList SyncedFolderItems to sort
+     * @param syncFolderItemList list of items to be sorted
+     * @return sorted list of items
      */
-    public static List<SyncedFolderItem> sortSyncedFolderItem(List<SyncedFolderItem> syncFolderItemList) {
-        Collections.sort(syncFolderItemList, new Comparator<SyncedFolderItem>() {
-            public int compare(SyncedFolderItem f1, SyncedFolderItem f2) {
+    public static List<SyncedFolderDisplayItem> sortSyncedFolderItems(List<SyncedFolderDisplayItem>
+                                                                              syncFolderItemList) {
+        Collections.sort(syncFolderItemList, new Comparator<SyncedFolderDisplayItem>() {
+            public int compare(SyncedFolderDisplayItem f1, SyncedFolderDisplayItem f2) {
                 if (f1 == null && f2 == null) {
                     return 0;
                 } else if (f1 == null) {
@@ -213,15 +208,15 @@ public class FolderSyncActivity extends FileActivity implements FolderSyncAdapte
     }
 
     /**
-     * creates a SyncedFolderItem merging a SyncedFolder and MediaFolder object instance.
+     * creates a SyncedFolderDisplayItem merging a {@link SyncedFolder} and a {@link MediaFolder} object instance.
      *
      * @param syncedFolder the synced folder object
      * @param mediaFolder  the media folder object
-     * @return the created SyncedFolderItem
+     * @return the created SyncedFolderDisplayItem
      */
     @NonNull
-    private SyncedFolderItem createSyncedFolder(@NonNull SyncedFolder syncedFolder, @NonNull MediaFolder mediaFolder) {
-        return new SyncedFolderItem(
+    private SyncedFolderDisplayItem createSyncedFolder(@NonNull SyncedFolder syncedFolder, @NonNull MediaFolder mediaFolder) {
+        return new SyncedFolderDisplayItem(
                 syncedFolder.getId(),
                 syncedFolder.getLocalPath(),
                 syncedFolder.getRemotePath(),
@@ -237,14 +232,14 @@ public class FolderSyncActivity extends FileActivity implements FolderSyncAdapte
     }
 
     /**
-     * creates a SyncedFolderItem based on a MediaFolder object instance.
+     * creates a {@link SyncedFolderDisplayItem} based on a {@link MediaFolder} object instance.
      *
      * @param mediaFolder the media folder object
-     * @return the created SyncedFolderItem
+     * @return the created SyncedFolderDisplayItem
      */
     @NonNull
-    private SyncedFolderItem createSyncedFolderFromMediaFolder(@NonNull MediaFolder mediaFolder) {
-        return new SyncedFolderItem(
+    private SyncedFolderDisplayItem createSyncedFolderFromMediaFolder(@NonNull MediaFolder mediaFolder) {
+        return new SyncedFolderDisplayItem(
                 UNPERSISTED_ID,
                 mediaFolder.absolutePath,
                 getString(R.string.instant_upload_path) + "/" + mediaFolder.folderName,
@@ -260,10 +255,10 @@ public class FolderSyncActivity extends FileActivity implements FolderSyncAdapte
     }
 
     /**
-     * creates a lookup map for a list of given synced folders with their local path as the key.
+     * creates a lookup map for a list of given {@link SyncedFolder}s with their local path as the key.
      *
-     * @param syncFolders list of synced folders
-     * @return the lookup map for synced folders
+     * @param syncFolders list of {@link SyncedFolder}s
+     * @return the lookup map for {@link SyncedFolder}s
      */
     @NonNull
     private Map<String, SyncedFolder> createSyncedFoldersMap(List<SyncedFolder> syncFolders) {
@@ -291,7 +286,7 @@ public class FolderSyncActivity extends FileActivity implements FolderSyncAdapte
 
     @Override
     public boolean onOptionsItemSelected(MenuItem item) {
-        boolean retval;
+        boolean result;
         switch (item.getItemId()) {
             case android.R.id.home: {
                 if (isDrawerOpen()) {
@@ -302,9 +297,9 @@ public class FolderSyncActivity extends FileActivity implements FolderSyncAdapte
             }
 
             default:
-                retval = super.onOptionsItemSelected(item);
+                result = super.onOptionsItemSelected(item);
         }
-        return retval;
+        return result;
     }
 
     @Override
@@ -323,21 +318,21 @@ public class FolderSyncActivity extends FileActivity implements FolderSyncAdapte
     }
 
     @Override
-    public void onSyncStatusToggleClick(int section, SyncedFolderItem syncedFolderItem) {
-        if (syncedFolderItem.getId() > UNPERSISTED_ID) {
-            mSyncedFolderProvider.updateFolderSyncEnabled(syncedFolderItem.getId(), syncedFolderItem.isEnabled());
+    public void onSyncStatusToggleClick(int section, SyncedFolderDisplayItem syncedFolderDisplayItem) {
+        if (syncedFolderDisplayItem.getId() > UNPERSISTED_ID) {
+            mSyncedFolderProvider.updateFolderSyncEnabled(syncedFolderDisplayItem.getId(), syncedFolderDisplayItem.isEnabled());
         } else {
-            mSyncedFolderProvider.storeFolderSync(syncedFolderItem);
+            mSyncedFolderProvider.storeFolderSync(syncedFolderDisplayItem);
         }
     }
 
     @Override
-    public void onSyncFolderSettingsClick(int section, SyncedFolderItem syncedFolderItem) {
+    public void onSyncFolderSettingsClick(int section, SyncedFolderDisplayItem syncedFolderDisplayItem) {
         FragmentManager fm = getSupportFragmentManager();
         FragmentTransaction ft = fm.beginTransaction();
         ft.addToBackStack(null);
 
-        mSyncedFolderPreferencesDialogFragment = SyncedFolderPreferencesDialogFragment.newInstance(syncedFolderItem,
+        mSyncedFolderPreferencesDialogFragment = SyncedFolderPreferencesDialogFragment.newInstance(syncedFolderDisplayItem,
                 section);
         mSyncedFolderPreferencesDialogFragment.show(ft, SYNCED_FOLDER_PREFERENCES_DIALOG_TAG);
     }
@@ -356,7 +351,7 @@ public class FolderSyncActivity extends FileActivity implements FolderSyncAdapte
 
     @Override
     public void onSaveSyncedFolderPreference(SyncedFolderParcelable syncedFolder) {
-        SyncedFolderItem item = syncFolderItems.get(syncedFolder.getSection());
+        SyncedFolderDisplayItem item = syncFolderItems.get(syncedFolder.getSection());
         item = updateSyncedFolderItem(item, syncedFolder.getLocalPath(), syncedFolder.getRemotePath(), syncedFolder
                 .getWifiOnly(), syncedFolder.getChargingOnly(), syncedFolder.getSubfolderByDate(), syncedFolder
                 .getUploadAction());
@@ -388,13 +383,13 @@ public class FolderSyncActivity extends FileActivity implements FolderSyncAdapte
      * @param uploadAction    upload action
      * @return the updated item
      */
-    private SyncedFolderItem updateSyncedFolderItem(SyncedFolderItem item,
-                                                    String localPath,
-                                                    String remotePath,
-                                                    Boolean wifiOnly,
-                                                    Boolean chargingOnly,
-                                                    Boolean subfolderByDate,
-                                                    Integer uploadAction) {
+    private SyncedFolderDisplayItem updateSyncedFolderItem(SyncedFolderDisplayItem item,
+                                                           String localPath,
+                                                           String remotePath,
+                                                           Boolean wifiOnly,
+                                                           Boolean chargingOnly,
+                                                           Boolean subfolderByDate,
+                                                           Integer uploadAction) {
         item.setLocalPath(localPath);
         item.setRemotePath(remotePath);
         item.setWifiOnly(wifiOnly);

+ 5 - 5
src/com/owncloud/android/ui/adapter/FolderSyncAdapter.java

@@ -34,7 +34,7 @@ import android.widget.TextView;
 
 import com.afollestad.sectionedrecyclerview.SectionedRecyclerViewAdapter;
 import com.owncloud.android.R;
-import com.owncloud.android.datamodel.SyncedFolderItem;
+import com.owncloud.android.datamodel.SyncedFolderDisplayItem;
 import com.owncloud.android.datamodel.ThumbnailsCacheManager;
 import com.owncloud.android.lib.common.utils.Log_OC;
 import com.owncloud.android.utils.BitmapUtils;
@@ -54,7 +54,7 @@ public class FolderSyncAdapter extends SectionedRecyclerViewAdapter<FolderSyncAd
     private final Context mContext;
     private final int mGridWidth;
     private final ClickListener mListener;
-    private final List<SyncedFolderItem> mSyncFolderItems;
+    private final List<SyncedFolderDisplayItem> mSyncFolderItems;
     private final RecyclerView mRecyclerView;
 
     public FolderSyncAdapter(Context context, int gridWidth, ClickListener listener, RecyclerView recyclerView) {
@@ -65,7 +65,7 @@ public class FolderSyncAdapter extends SectionedRecyclerViewAdapter<FolderSyncAd
         mRecyclerView = recyclerView;
     }
 
-    public void setSyncFolderItems(List<SyncedFolderItem> syncFolderItems) {
+    public void setSyncFolderItems(List<SyncedFolderDisplayItem> syncFolderItems) {
         mSyncFolderItems.clear();
         mSyncFolderItems.addAll(syncFolderItems);
         notifyDataSetChanged();
@@ -186,8 +186,8 @@ public class FolderSyncAdapter extends SectionedRecyclerViewAdapter<FolderSyncAd
     }
 
     public interface ClickListener {
-        void onSyncStatusToggleClick(int section, SyncedFolderItem syncedFolderItem);
-        void onSyncFolderSettingsClick(int section, SyncedFolderItem syncedFolderItem);
+        void onSyncStatusToggleClick(int section, SyncedFolderDisplayItem syncedFolderDisplayItem);
+        void onSyncFolderSettingsClick(int section, SyncedFolderDisplayItem syncedFolderDisplayItem);
     }
 
     static class MainViewHolder extends RecyclerView.ViewHolder {

+ 2 - 2
src/com/owncloud/android/ui/dialog/SyncedFolderPreferencesDialogFragment.java

@@ -36,7 +36,7 @@ import android.widget.CheckBox;
 import android.widget.TextView;
 
 import com.owncloud.android.R;
-import com.owncloud.android.datamodel.SyncedFolderItem;
+import com.owncloud.android.datamodel.SyncedFolderDisplayItem;
 import com.owncloud.android.lib.common.utils.Log_OC;
 import com.owncloud.android.ui.activity.FolderPickerActivity;
 import com.owncloud.android.ui.dialog.parcel.SyncedFolderParcelable;
@@ -65,7 +65,7 @@ public class SyncedFolderPreferencesDialogFragment extends DialogFragment {
     private SyncedFolderParcelable mSyncedFolder;
     private int mSection;
 
-    public static SyncedFolderPreferencesDialogFragment newInstance(SyncedFolderItem syncedFolder, int section) {
+    public static SyncedFolderPreferencesDialogFragment newInstance(SyncedFolderDisplayItem syncedFolder, int section) {
         SyncedFolderPreferencesDialogFragment dialogFragment = new SyncedFolderPreferencesDialogFragment();
 
         if (syncedFolder == null) {

+ 13 - 13
src/com/owncloud/android/ui/dialog/parcel/SyncedFolderParcelable.java

@@ -23,10 +23,10 @@ package com.owncloud.android.ui.dialog.parcel;
 import android.os.Parcel;
 import android.os.Parcelable;
 
-import com.owncloud.android.datamodel.SyncedFolderItem;
+import com.owncloud.android.datamodel.SyncedFolderDisplayItem;
 
 /**
- * Parceble for SyncedFolder objects to transport them from/to dialog fragments.
+ * Parcelable for {@link SyncedFolderDisplayItem} objects to transport them from/to dialog fragments.
  */
 public class SyncedFolderParcelable implements Parcelable {
     private String mLocalPath;
@@ -43,20 +43,20 @@ public class SyncedFolderParcelable implements Parcelable {
     public SyncedFolderParcelable() {
     }
 
-    public SyncedFolderParcelable(SyncedFolderItem syncedFolderItem, int section) {
-        mId = syncedFolderItem.getId();
-        mLocalPath = syncedFolderItem.getLocalPath();
-        mRemotePath = syncedFolderItem.getRemotePath();
-        mWifiOnly = syncedFolderItem.getWifiOnly();
-        mChargingOnly = syncedFolderItem.getChargingOnly();
-        mEnabled = syncedFolderItem.isEnabled();
-        mSubfolderByDate = syncedFolderItem.getSubfolderByDate();
-        mAccount = syncedFolderItem.getAccount();
-        mUploadAction = syncedFolderItem.getUploadAction();
+    public SyncedFolderParcelable(SyncedFolderDisplayItem syncedFolderDisplayItem, int section) {
+        mId = syncedFolderDisplayItem.getId();
+        mLocalPath = syncedFolderDisplayItem.getLocalPath();
+        mRemotePath = syncedFolderDisplayItem.getRemotePath();
+        mWifiOnly = syncedFolderDisplayItem.getWifiOnly();
+        mChargingOnly = syncedFolderDisplayItem.getChargingOnly();
+        mEnabled = syncedFolderDisplayItem.isEnabled();
+        mSubfolderByDate = syncedFolderDisplayItem.getSubfolderByDate();
+        mAccount = syncedFolderDisplayItem.getAccount();
+        mUploadAction = syncedFolderDisplayItem.getUploadAction();
         mSection = section;
     }
 
-    public SyncedFolderParcelable(Parcel read) {
+    private SyncedFolderParcelable(Parcel read) {
         mId = read.readLong();
         mLocalPath = read.readString();
         mRemotePath = read.readString();