implementation of #1193 - optimizing the uploader layout and taking user configured sorting into account

This commit is contained in:
Andy Scherzinger 2015-11-09 18:24:57 +01:00
parent 932c66d4c5
commit d74f5fdc2a
7 changed files with 100 additions and 56 deletions

View file

@ -73,7 +73,9 @@
<activity android:name=".ui.activity.UploadFilesActivity" />
<activity android:name=".ui.activity.ReceiveExternalFilesActivity"
android:taskAffinity=""
android:excludeFromRecents="true">
android:excludeFromRecents="true"
android:label="@string/uploader_top_message"
android:theme="@style/Theme.ownCloud">
<intent-filter>
<action android:name="android.intent.action.SEND" />

View file

@ -18,25 +18,19 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content" android:orientation="vertical"
android:layout_width="wrap_content" android:background="#fefefe"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_width="wrap_content"
android:gravity="center">
<TextView android:layout_width="fill_parent"
android:text="@string/uploader_top_message"
android:layout_height="wrap_content"
android:id="@+id/drawer_username"
android:textColor="@android:color/black"
android:gravity="center_horizontal">
</TextView>
<FrameLayout android:layout_height="fill_parent"
<FrameLayout
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:id="@+id/frameLayout1"
android:layout_below="@+id/drawer_username"
android:layout_above="@+id/linearLayout1">
android:id="@+id/upload_list"
android:layout_above="@+id/upload_actions">
<ListView android:id="@android:id/list"
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:divider="@color/list_divider_background"
@ -46,7 +40,7 @@
</FrameLayout>
<LinearLayout
android:id="@+id/linearLayout1"
android:id="@+id/upload_actions"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"

View file

@ -17,28 +17,57 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:background="#fefefe"
android:orientation="horizontal"
android:layout_height="72dp"
android:padding="@dimen/standard_padding">
android:layout_height="56dp"
android:background="@drawable/list_selector"
android:orientation="horizontal">
<LinearLayout
android:layout_width="56dp"
android:layout_height="56dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/thumbnail"
android:layout_width="@dimen/file_icon_size"
android:layout_height="@dimen/file_icon_size"
android:layout_gravity="center_vertical|center"
android:src="@drawable/ic_menu_archive"
android:id="@+id/thumbnail"
android:layout_marginRight="@dimen/standard_padding"/>
android:layout_gravity="center_vertical"
android:layout_marginLeft="12dp"
android:src="@drawable/ic_menu_archive" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="vertical">
<TextView
android:text="TextView"
android:layout_width="fill_parent"
android:id="@+id/filename"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/black"
android:textSize="16sp" />
android:layout_gravity="center_vertical"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:ellipsize="middle"
android:singleLine="true"
android:text="TextView"
android:textColor="@color/textColor"
android:textSize="16dip" />
<TextView
android:id="@+id/last_mod"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:text="TextView"
android:textColor="@color/list_item_lastmod_and_filesize_text"
android:textSize="12dip" />
</LinearLayout>
</LinearLayout>

View file

@ -61,7 +61,7 @@
<string name="sync_string_files">Files</string>
<string name="setup_btn_connect">Connect</string>
<string name="uploader_btn_upload_text">Upload</string>
<string name="uploader_top_message">Choose upload folder:</string>
<string name="uploader_top_message">Choose upload folder</string>
<string name="uploader_wrn_no_account_title">No account found</string>
<string name="uploader_wrn_no_account_text">There are no %1$s accounts on your device. Please set up an account first.</string>
<string name="uploader_wrn_no_account_setup_btn_text">Setup</string>

View file

@ -73,6 +73,7 @@ import com.owncloud.android.ui.fragment.TaskRetainerFragment;
import com.owncloud.android.ui.helpers.UriUploader;
import com.owncloud.android.utils.DisplayUtils;
import com.owncloud.android.utils.ErrorMessageAdapter;
import com.owncloud.android.utils.FileStorageUtils;
import java.util.ArrayList;
import java.util.HashMap;
@ -313,6 +314,8 @@ public class ReceiveExternalFilesActivity extends FileActivity
Log_OC.d(TAG, "on item click");
// TODO Enable when "On Device" is recovered ?
Vector<OCFile> tmpfiles = getStorageManager().getFolderContent(mFile /*, false*/);
tmpfiles = sortFileList(tmpfiles);
if (tmpfiles.size() <= 0) return;
// filter on dirtype
Vector<OCFile> files = new Vector<>();
@ -378,15 +381,16 @@ public class ReceiveExternalFilesActivity 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);
@ -398,10 +402,14 @@ public class ReceiveExternalFilesActivity extends FileActivity
if (mFile != null) {
// TODO Enable when "On Device" is recovered ?
Vector<OCFile> files = getStorageManager().getFolderContent(mFile/*, false*/);
List<HashMap<String, OCFile>> data = new LinkedList<>();
files = sortFileList(files);
List<HashMap<String, Object>> data = new LinkedList<>();
for (OCFile f : files) {
HashMap<String, OCFile> h = new HashMap<>();
h.put("dirname", f);
if (f.isFolder()) {
HashMap<String, Object> h = new HashMap<>();
h.put("dirname", f.getFileName());
h.put("last_mod", DisplayUtils.getRelativeTimestamp(this, f));
data.add(h);
}
@ -409,7 +417,7 @@ public class ReceiveExternalFilesActivity extends FileActivity
data,
R.layout.uploader_list_item_layout,
new String[] {"dirname"},
new int[] {R.id.filename},
new int[] {R.id.filename, R.id.last_mod});
getStorageManager(), getAccount());
mListView.setAdapter(sa);
@ -446,6 +454,17 @@ public class ReceiveExternalFilesActivity extends FileActivity
synchFolderOp.execute(getAccount(), this, null, null);
}
private Vector<OCFile> sortFileList(Vector<OCFile> 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<String> dirs) {
String full_path = "";

View file

@ -199,7 +199,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);
@ -444,11 +444,6 @@ public class FileListListAdapter extends BaseAdapter implements ListAdapter {
}
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;
}

View file

@ -172,8 +172,13 @@ public class DisplayUtils {
}
}
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
){