|
@@ -38,9 +38,13 @@ import android.graphics.PorterDuff;
|
|
|
import android.graphics.drawable.ColorDrawable;
|
|
|
import android.graphics.drawable.Drawable;
|
|
|
import android.os.Bundle;
|
|
|
+import android.os.Handler;
|
|
|
+import android.os.Looper;
|
|
|
import android.os.Parcelable;
|
|
|
+import android.support.annotation.DrawableRes;
|
|
|
import android.support.annotation.NonNull;
|
|
|
import android.support.annotation.Nullable;
|
|
|
+import android.support.annotation.StringRes;
|
|
|
import android.support.v4.app.DialogFragment;
|
|
|
import android.support.v4.app.FragmentManager;
|
|
|
import android.support.v4.content.ContextCompat;
|
|
@@ -60,7 +64,10 @@ import android.widget.AdapterView.OnItemClickListener;
|
|
|
import android.widget.ArrayAdapter;
|
|
|
import android.widget.Button;
|
|
|
import android.widget.EditText;
|
|
|
+import android.widget.ImageView;
|
|
|
+import android.widget.LinearLayout;
|
|
|
import android.widget.ListView;
|
|
|
+import android.widget.ProgressBar;
|
|
|
import android.widget.Spinner;
|
|
|
import android.widget.TextView;
|
|
|
import android.widget.Toast;
|
|
@@ -143,6 +150,12 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
|
|
|
|
|
private final static String FILENAME_ENCODING = "UTF-8";
|
|
|
|
|
|
+ private LinearLayout mEmptyListContainer;
|
|
|
+ private TextView mEmptyListMessage;
|
|
|
+ private TextView mEmptyListHeadline;
|
|
|
+ private ImageView mEmptyListIcon;
|
|
|
+ private ProgressBar mEmptyListProgress;
|
|
|
+
|
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
prepareStreamsToUpload();
|
|
@@ -711,6 +724,7 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
|
|
|
|
|
private void populateDirectoryList() {
|
|
|
setContentView(R.layout.uploader_layout);
|
|
|
+ setupEmptyList();
|
|
|
setupToolbar();
|
|
|
ActionBar actionBar = getSupportActionBar();
|
|
|
|
|
@@ -735,41 +749,85 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
|
|
mFile = getStorageManager().getFileByPath(full_path);
|
|
|
if (mFile != null) {
|
|
|
Vector<OCFile> files = getStorageManager().getFolderContent(mFile, false);
|
|
|
- sortFileList(files);
|
|
|
|
|
|
- List<HashMap<String, Object>> data = new LinkedList<>();
|
|
|
- for (OCFile f : files) {
|
|
|
- HashMap<String, Object> h = new HashMap<>();
|
|
|
- h.put("dirname", f);
|
|
|
- data.add(h);
|
|
|
- }
|
|
|
+ if (files.size() == 0) {
|
|
|
+ setMessageForEmptyList(
|
|
|
+ R.string.file_list_empty_headline,
|
|
|
+ R.string.empty,
|
|
|
+ R.drawable.ic_list_empty_upload,
|
|
|
+ true
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ mEmptyListContainer.setVisibility(View.GONE);
|
|
|
|
|
|
- UploaderAdapter sa = new UploaderAdapter(this,
|
|
|
- data,
|
|
|
- R.layout.uploader_list_item_layout,
|
|
|
- new String[] {"dirname"},
|
|
|
- new int[] {R.id.filename},
|
|
|
- getStorageManager(), getAccount());
|
|
|
+ sortFileList(files);
|
|
|
+
|
|
|
+ List<HashMap<String, Object>> data = new LinkedList<>();
|
|
|
+ for (OCFile f : files) {
|
|
|
+ HashMap<String, Object> h = new HashMap<>();
|
|
|
+ h.put("dirname", f);
|
|
|
+ data.add(h);
|
|
|
+ }
|
|
|
|
|
|
- mListView.setAdapter(sa);
|
|
|
- Button btnChooseFolder = (Button) findViewById(R.id.uploader_choose_folder);
|
|
|
- btnChooseFolder.setOnClickListener(this);
|
|
|
- btnChooseFolder.getBackground().setColorFilter(ThemeUtils.primaryColor(getAccount()),
|
|
|
- PorterDuff.Mode.SRC_ATOP);
|
|
|
+ UploaderAdapter sa = new UploaderAdapter(this,
|
|
|
+ data,
|
|
|
+ R.layout.uploader_list_item_layout,
|
|
|
+ new String[]{"dirname"},
|
|
|
+ new int[]{R.id.filename},
|
|
|
+ getStorageManager(), getAccount());
|
|
|
|
|
|
- getSupportActionBar().setBackgroundDrawable(new ColorDrawable(ThemeUtils.primaryColor(getAccount())));
|
|
|
+ mListView.setAdapter(sa);
|
|
|
+ Button btnChooseFolder = (Button) findViewById(R.id.uploader_choose_folder);
|
|
|
+ btnChooseFolder.setOnClickListener(this);
|
|
|
+ btnChooseFolder.getBackground().setColorFilter(ThemeUtils.primaryColor(getAccount()),
|
|
|
+ PorterDuff.Mode.SRC_ATOP);
|
|
|
|
|
|
- ThemeUtils.colorStatusBar(this, ThemeUtils.primaryDarkColor(getAccount()));
|
|
|
+ getSupportActionBar().setBackgroundDrawable(new ColorDrawable(ThemeUtils.primaryColor(getAccount())));
|
|
|
|
|
|
- ThemeUtils.colorToolbarProgressBar(this, ThemeUtils.primaryColor(getAccount()));
|
|
|
+ ThemeUtils.colorStatusBar(this, ThemeUtils.primaryDarkColor(getAccount()));
|
|
|
|
|
|
- Button btnNewFolder = (Button) findViewById(R.id.uploader_cancel);
|
|
|
- btnNewFolder.setOnClickListener(this);
|
|
|
+ ThemeUtils.colorToolbarProgressBar(this, ThemeUtils.primaryColor(getAccount()));
|
|
|
|
|
|
- mListView.setOnItemClickListener(this);
|
|
|
+ Button btnNewFolder = (Button) findViewById(R.id.uploader_cancel);
|
|
|
+ btnNewFolder.setOnClickListener(this);
|
|
|
+
|
|
|
+ mListView.setOnItemClickListener(this);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ protected void setupEmptyList() {
|
|
|
+ mEmptyListContainer = (LinearLayout) findViewById(R.id.empty_list_view);
|
|
|
+ mEmptyListMessage = (TextView) findViewById(R.id.empty_list_view_text);
|
|
|
+ mEmptyListHeadline = (TextView) findViewById(R.id.empty_list_view_headline);
|
|
|
+ mEmptyListIcon = (ImageView) findViewById(R.id.empty_list_icon);
|
|
|
+ mEmptyListProgress = (ProgressBar) findViewById(R.id.empty_list_progress);
|
|
|
+ mEmptyListProgress.getIndeterminateDrawable().setColorFilter(ThemeUtils.primaryColor(),
|
|
|
+ PorterDuff.Mode.SRC_IN);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setMessageForEmptyList(@StringRes final int headline, @StringRes final int message,
|
|
|
+ @DrawableRes final int icon, final boolean tintIcon) {
|
|
|
+ new Handler(Looper.getMainLooper()).post(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+
|
|
|
+ if (mEmptyListContainer != null && mEmptyListMessage != null) {
|
|
|
+ mEmptyListHeadline.setText(headline);
|
|
|
+ mEmptyListMessage.setText(message);
|
|
|
+
|
|
|
+ if (tintIcon) {
|
|
|
+ mEmptyListIcon.setImageDrawable(ThemeUtils.tintDrawable(icon, ThemeUtils.primaryColor()));
|
|
|
+ }
|
|
|
+
|
|
|
+ mEmptyListIcon.setVisibility(View.VISIBLE);
|
|
|
+ mEmptyListProgress.setVisibility(View.GONE);
|
|
|
+ mEmptyListMessage.setVisibility(View.VISIBLE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void onSavedCertificate() {
|
|
|
startSyncFolderOperation(getCurrentDir());
|