From: Andy Scherzinger Date: Mon, 9 Nov 2015 17:24:57 +0000 (+0100) Subject: implementation of #1193 - optimizing the uploader layout and taking user configured... X-Git-Tag: beta-20151122~8^2~1 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/50dc074919b966b9ffde29c768e55b1926fd69f0?ds=inline;hp=-c implementation of #1193 - optimizing the uploader layout and taking user configured sorting into account --- 50dc074919b966b9ffde29c768e55b1926fd69f0 diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 805e9ce7..b4c483a3 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -59,7 +59,9 @@ - + diff --git a/res/layout/uploader_layout.xml b/res/layout/uploader_layout.xml index 79b077dc..601ac606 100644 --- a/res/layout/uploader_layout.xml +++ b/res/layout/uploader_layout.xml @@ -18,35 +18,29 @@ along with this program. If not, see . --> - - - - + android:id="@+id/upload_list" + android:layout_above="@+id/upload_actions"> - + android:divider="#eee" + android:dividerHeight="1dp"> . --> - - - - - - + + + + + + + + + + + + + + + + diff --git a/res/values/strings.xml b/res/values/strings.xml index 320eea1a..abe72822 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -62,7 +62,7 @@ Connect Upload New folder - Choose upload folder: + Choose upload folder No account found There are no %1$s accounts on your device. Please setup an account first. Setup diff --git a/src/com/owncloud/android/ui/activity/Uploader.java b/src/com/owncloud/android/ui/activity/Uploader.java index 0d1a8011..99ca54ec 100644 --- a/src/com/owncloud/android/ui/activity/Uploader.java +++ b/src/com/owncloud/android/ui/activity/Uploader.java @@ -84,6 +84,7 @@ import com.owncloud.android.ui.dialog.LoadingDialog; import com.owncloud.android.utils.CopyTmpFileAsyncTask; import com.owncloud.android.utils.DisplayUtils; import com.owncloud.android.utils.ErrorMessageAdapter; +import com.owncloud.android.utils.FileStorageUtils; /** @@ -335,6 +336,8 @@ public class Uploader extends FileActivity Log_OC.d(TAG, "on item click"); // TODO Enable when "On Device" is recovered ? Vector tmpfiles = getStorageManager().getFolderContent(mFile /*, false*/); + tmpfiles = sortFileList(tmpfiles); + if (tmpfiles.size() <= 0) return; // filter on dirtype Vector files = new Vector(); @@ -399,16 +402,17 @@ public class Uploader extends FileActivity setContentView(R.layout.uploader_layout); ListView mListView = (ListView) findViewById(android.R.id.list); + ActionBar actionBar = getSupportActionBar(); String current_dir = mParents.peek(); if(current_dir.equals("")){ - getSupportActionBar().setTitle(getString(R.string.default_display_name_for_root_folder)); + actionBar.setTitle(getString(R.string.uploader_top_message)); } else{ - getSupportActionBar().setTitle(current_dir); + actionBar.setTitle(current_dir); } boolean notRoot = (mParents.size() > 1); - ActionBar actionBar = getSupportActionBar(); + actionBar.setDisplayHomeAsUpEnabled(notRoot); actionBar.setHomeButtonEnabled(notRoot); @@ -420,19 +424,22 @@ public class Uploader extends FileActivity if (mFile != null) { // TODO Enable when "On Device" is recovered ? Vector files = getStorageManager().getFolderContent(mFile/*, false*/); + files = sortFileList(files); + List> data = new LinkedList>(); for (OCFile f : files) { - HashMap h = new HashMap(); if (f.isFolder()) { + HashMap h = new HashMap(); h.put("dirname", f.getFileName()); + h.put("last_mod", DisplayUtils.getRelativeTimestamp(this, f)); data.add(h); } } SimpleAdapter sa = new SimpleAdapter(this, data, R.layout.uploader_list_item_layout, - new String[] {"dirname"}, - new int[] {R.id.filename}); + new String[] {"dirname", "last_mod"}, + new int[] {R.id.filename, R.id.last_mod}); mListView.setAdapter(sa); Button btnChooseFolder = (Button) findViewById(R.id.uploader_choose_folder); @@ -445,6 +452,18 @@ public class Uploader extends FileActivity } } + private Vector sortFileList(Vector files) { + SharedPreferences sharedPreferences = PreferenceManager + .getDefaultSharedPreferences(this); + + // Read sorting order, default to sort by name ascending + FileStorageUtils.mSortOrder = sharedPreferences.getInt("sortOrder", 0); + FileStorageUtils.mSortAscending = sharedPreferences.getBoolean("sortAscending", true); + + files = FileStorageUtils.sortFolder(files); + return files; + } + private String generatePath(Stack dirs) { String full_path = ""; diff --git a/src/com/owncloud/android/ui/adapter/FileListListAdapter.java b/src/com/owncloud/android/ui/adapter/FileListListAdapter.java index 07a3eed5..975095b5 100644 --- a/src/com/owncloud/android/ui/adapter/FileListListAdapter.java +++ b/src/com/owncloud/android/ui/adapter/FileListListAdapter.java @@ -197,7 +197,7 @@ public class FileListListAdapter extends BaseAdapter implements ListAdapter { ImageView checkBoxV = (ImageView) view.findViewById(R.id.custom_checkbox); lastModV.setVisibility(View.VISIBLE); - lastModV.setText(showRelativeTimestamp(file)); + lastModV.setText(DisplayUtils.getRelativeTimestamp(mContext, file)); checkBoxV.setVisibility(View.GONE); @@ -446,11 +446,6 @@ public class FileListListAdapter extends BaseAdapter implements ListAdapter { notifyDataSetChanged(); } - - private CharSequence showRelativeTimestamp(OCFile file){ - return DisplayUtils.getRelativeDateTimeString(mContext, file.getModificationTimestamp(), - DateUtils.SECOND_IN_MILLIS, DateUtils.WEEK_IN_MILLIS, 0); - } public void setGridMode(boolean gridMode) { mGridMode = gridMode; diff --git a/src/com/owncloud/android/utils/DisplayUtils.java b/src/com/owncloud/android/utils/DisplayUtils.java index a30595c3..b6eaa895 100644 --- a/src/com/owncloud/android/utils/DisplayUtils.java +++ b/src/com/owncloud/android/utils/DisplayUtils.java @@ -178,8 +178,13 @@ public class DisplayUtils { return fileExtension; } + public static CharSequence getRelativeTimestamp(Context context, OCFile file) { + return getRelativeDateTimeString(context, file.getModificationTimestamp(), + DateUtils.SECOND_IN_MILLIS, DateUtils.WEEK_IN_MILLIS, 0); + } + @SuppressWarnings("deprecation") - public static CharSequence getRelativeDateTimeString ( + private static CharSequence getRelativeDateTimeString ( Context c, long time, long minResolution, long transitionResolution, int flags ){