root / src / com / rackspace / cloud / android / ContainerObjectsActivity.java @ 6ba04c48
History | View | Annotate | Download (38.6 kB)
1 | 7dbfc514 | koutsoub | package com.rackspace.cloud.android; |
---|---|---|---|
2 | 3d6041e8 | Phillip Toohill | |
3 | 802fbd9e | koutsoub | |
4 | 802fbd9e | koutsoub | |
5 | 802fbd9e | koutsoub | import java.io.File; |
6 | 802fbd9e | koutsoub | import java.net.URLEncoder; |
7 | 3d6041e8 | Phillip Toohill | import java.util.ArrayList; |
8 | d3ea294b | Adam Menz | import java.util.Arrays; |
9 | 802fbd9e | koutsoub | import java.util.List; |
10 | 3d6041e8 | Phillip Toohill | |
11 | 3d6041e8 | Phillip Toohill | import org.apache.http.HttpResponse; |
12 | 3d6041e8 | Phillip Toohill | |
13 | 3d6041e8 | Phillip Toohill | import android.app.Activity; |
14 | 3d6041e8 | Phillip Toohill | import android.app.AlertDialog; |
15 | 3d6041e8 | Phillip Toohill | import android.app.Dialog; |
16 | 802fbd9e | koutsoub | import android.content.ActivityNotFoundException; |
17 | 3d6041e8 | Phillip Toohill | import android.content.DialogInterface; |
18 | 3d6041e8 | Phillip Toohill | import android.content.Intent; |
19 | 802fbd9e | koutsoub | import android.database.Cursor; |
20 | 802fbd9e | koutsoub | import android.net.Uri; |
21 | 3d6041e8 | Phillip Toohill | import android.os.AsyncTask; |
22 | 3d6041e8 | Phillip Toohill | import android.os.Bundle; |
23 | ef6fa21a | koutsoub | import android.util.Log; |
24 | ecbad159 | koutsoub | import android.view.ContextMenu; |
25 | ecbad159 | koutsoub | import android.view.ContextMenu.ContextMenuInfo; |
26 | 3d6041e8 | Phillip Toohill | import android.view.LayoutInflater; |
27 | 3d6041e8 | Phillip Toohill | import android.view.Menu; |
28 | 3d6041e8 | Phillip Toohill | import android.view.MenuInflater; |
29 | 3d6041e8 | Phillip Toohill | import android.view.MenuItem; |
30 | 3d6041e8 | Phillip Toohill | import android.view.View; |
31 | 3d6041e8 | Phillip Toohill | import android.view.ViewGroup; |
32 | 802fbd9e | koutsoub | import android.webkit.MimeTypeMap; |
33 | ecbad159 | koutsoub | import android.widget.AdapterView; |
34 | 3d6041e8 | Phillip Toohill | import android.widget.ArrayAdapter; |
35 | d3ea294b | Adam Menz | import android.widget.EditText; |
36 | f506786e | Adam Menz | import android.widget.ImageView; |
37 | 3d6041e8 | Phillip Toohill | import android.widget.ListView; |
38 | 3d6041e8 | Phillip Toohill | import android.widget.TextView; |
39 | 802fbd9e | koutsoub | import android.widget.Toast; |
40 | 3d6041e8 | Phillip Toohill | |
41 | 3d6041e8 | Phillip Toohill | import com.rackspace.cloud.files.api.client.Container; |
42 | 3d6041e8 | Phillip Toohill | import com.rackspace.cloud.files.api.client.ContainerManager; |
43 | 3d6041e8 | Phillip Toohill | import com.rackspace.cloud.files.api.client.ContainerObjectManager; |
44 | 3d6041e8 | Phillip Toohill | import com.rackspace.cloud.files.api.client.ContainerObjects; |
45 | fc8b1f79 | koutsoub | import com.rackspace.cloud.files.api.client.parsers.OthersXmlParser; |
46 | 3d6041e8 | Phillip Toohill | import com.rackspace.cloud.servers.api.client.CloudServersException; |
47 | 32731215 | Adam Menz | import com.rackspace.cloud.servers.api.client.http.HttpBundle; |
48 | 3d6041e8 | Phillip Toohill | |
49 | 240418be | Phillip Toohill | /**
|
50 | 3d6041e8 | Phillip Toohill | *
|
51 | 3d6041e8 | Phillip Toohill | * @author Phillip Toohill
|
52 | 240418be | Phillip Toohill | *
|
53 | 3d6041e8 | Phillip Toohill | */
|
54 | 6b8dad86 | Adam Menz | |
55 | b2a2d2f1 | Adam Menz | public class ContainerObjectsActivity extends CloudListActivity { |
56 | 3d6041e8 | Phillip Toohill | |
57 | 3d6041e8 | Phillip Toohill | private static final int deleteContainer = 0; |
58 | 37a14877 | Adam Menz | private static final int deleteFolder = 1; |
59 | 7b27f0dc | koutsoub | private static final int deleteContext = 2; |
60 | 7b27f0dc | koutsoub | private static final int toTrashContext = 3; |
61 | 7b27f0dc | koutsoub | private static final int fromTrashContext = 4; |
62 | 7b27f0dc | koutsoub | private String currentSelectedPath=null; |
63 | 3d6041e8 | Phillip Toohill | private ContainerObjects[] files; |
64 | 3d6041e8 | Phillip Toohill | private static Container container; |
65 | 3d6041e8 | Phillip Toohill | public String LOG = "viewFilesActivity"; |
66 | 8b432514 | Phillip Toohill | private String cdnEnabledIs; |
67 | 6864568a | Phillip Toohill | public Object megaBytes; |
68 | 6864568a | Phillip Toohill | public Object kiloBytes; |
69 | 6864568a | Phillip Toohill | public int bConver = 1048576; |
70 | 6864568a | Phillip Toohill | public int kbConver = 1024; |
71 | 51938302 | Adam Menz | private boolean loadingFiles; |
72 | b2a2d2f1 | Adam Menz | private String currentPath; |
73 | a7d1fdc2 | Adam Menz | private AndroidCloudApplication app;
|
74 | a7d1fdc2 | Adam Menz | private AddObjectListenerTask task;
|
75 | a7d1fdc2 | Adam Menz | private DeleteObjectListenerTask deleteObjTask;
|
76 | a7d1fdc2 | Adam Menz | private DeleteContainerListenerTask deleteContainerTask;
|
77 | 94abc2c7 | koutsoub | |
78 | 71e52c4a | Adam Menz | |
79 | 3d6041e8 | Phillip Toohill | @Override
|
80 | 240418be | Phillip Toohill | public void onCreate(Bundle savedInstanceState) { |
81 | 240418be | Phillip Toohill | super.onCreate(savedInstanceState);
|
82 | 5018a7f8 | Adam Menz | trackPageView(GoogleAnalytics.PAGE_FOLDER); |
83 | 856ad13d | koutsoub | container = getContainer(); |
84 | 240418be | Phillip Toohill | if (container.isCdnEnabled() == true) { |
85 | 240418be | Phillip Toohill | cdnEnabledIs = "true";
|
86 | 240418be | Phillip Toohill | } else {
|
87 | 240418be | Phillip Toohill | cdnEnabledIs = "false";
|
88 | 240418be | Phillip Toohill | } |
89 | ecbad159 | koutsoub | |
90 | 240418be | Phillip Toohill | restoreState(savedInstanceState); |
91 | 240418be | Phillip Toohill | } |
92 | 802fbd9e | koutsoub | |
93 | 802fbd9e | koutsoub | protected Container getContainer() { |
94 | 856ad13d | koutsoub | return (Container) this.getIntent().getExtras().get("container"); |
95 | 856ad13d | koutsoub | } |
96 | 802fbd9e | koutsoub | |
97 | 3d6041e8 | Phillip Toohill | @Override
|
98 | 3d6041e8 | Phillip Toohill | protected void onSaveInstanceState(Bundle outState) { |
99 | 3d6041e8 | Phillip Toohill | super.onSaveInstanceState(outState);
|
100 | 71e52c4a | Adam Menz | |
101 | 802fbd9e | koutsoub | // files stores all the files in the container
|
102 | 3d6041e8 | Phillip Toohill | outState.putSerializable("container", files);
|
103 | 71e52c4a | Adam Menz | |
104 | 802fbd9e | koutsoub | // current path represents where you have "navigated" to
|
105 | c16dc9e7 | Adam Menz | outState.putString("path", currentPath);
|
106 | 71e52c4a | Adam Menz | |
107 | 51938302 | Adam Menz | outState.putBoolean("loadingFiles", loadingFiles);
|
108 | 3d6041e8 | Phillip Toohill | } |
109 | a7d1fdc2 | Adam Menz | |
110 | b2a2d2f1 | Adam Menz | protected void restoreState(Bundle state) { |
111 | b2a2d2f1 | Adam Menz | super.restoreState(state);
|
112 | 7b27f0dc | koutsoub | |
113 | a7d1fdc2 | Adam Menz | /*
|
114 | 802fbd9e | koutsoub | * need reference to the app so you can access curDirFiles as well as
|
115 | 802fbd9e | koutsoub | * processing status
|
116 | a7d1fdc2 | Adam Menz | */
|
117 | 802fbd9e | koutsoub | app = (AndroidCloudApplication) this.getApplication();
|
118 | a7d1fdc2 | Adam Menz | |
119 | 802fbd9e | koutsoub | if (state != null) { |
120 | 802fbd9e | koutsoub | if (state.containsKey("path")) { |
121 | d3ea294b | Adam Menz | currentPath = state.getString("path");
|
122 | 802fbd9e | koutsoub | } else {
|
123 | d3ea294b | Adam Menz | currentPath = "";
|
124 | d3ea294b | Adam Menz | } |
125 | a7d1fdc2 | Adam Menz | |
126 | 802fbd9e | koutsoub | if (state.containsKey("loadingFiles") |
127 | 802fbd9e | koutsoub | && state.getBoolean("loadingFiles")) {
|
128 | 51938302 | Adam Menz | loadFiles(); |
129 | 802fbd9e | koutsoub | } else if (state.containsKey("container")) { |
130 | 71e52c4a | Adam Menz | files = (ContainerObjects[]) state.getSerializable("container"); |
131 | 71e52c4a | Adam Menz | if (app.getCurFiles() == null || app.getCurFiles().size() == 0) { |
132 | 71e52c4a | Adam Menz | displayNoFilesCell(); |
133 | 71e52c4a | Adam Menz | } else {
|
134 | 71e52c4a | Adam Menz | getListView().setDividerHeight(1); // restore divider lines |
135 | 71e52c4a | Adam Menz | setListAdapter(new FileAdapter());
|
136 | a7d1fdc2 | Adam Menz | |
137 | d3ea294b | Adam Menz | } |
138 | 71e52c4a | Adam Menz | |
139 | 240418be | Phillip Toohill | } |
140 | 802fbd9e | koutsoub | } else {
|
141 | d3ea294b | Adam Menz | currentPath = "";
|
142 | d3ea294b | Adam Menz | loadFiles(); |
143 | 802fbd9e | koutsoub | } |
144 | 71e52c4a | Adam Menz | |
145 | a7d1fdc2 | Adam Menz | /*
|
146 | 802fbd9e | koutsoub | * if the app is process when we enter the activity we must listen for
|
147 | 802fbd9e | koutsoub | * the new curDirFiles list
|
148 | a7d1fdc2 | Adam Menz | */
|
149 | 802fbd9e | koutsoub | if (app.isAddingObject()) {
|
150 | a7d1fdc2 | Adam Menz | task = new AddObjectListenerTask();
|
151 | a7d1fdc2 | Adam Menz | task.execute(); |
152 | a7d1fdc2 | Adam Menz | } |
153 | 71e52c4a | Adam Menz | |
154 | 802fbd9e | koutsoub | if (app.isDeletingObject()) {
|
155 | a7d1fdc2 | Adam Menz | displayNoFilesCell(); |
156 | a7d1fdc2 | Adam Menz | deleteObjTask = new DeleteObjectListenerTask();
|
157 | a7d1fdc2 | Adam Menz | deleteObjTask.execute(); |
158 | a7d1fdc2 | Adam Menz | } |
159 | 71e52c4a | Adam Menz | |
160 | 802fbd9e | koutsoub | if (app.isDeletingContainer()) {
|
161 | 877f6f58 | Adam Menz | displayNoFilesCell(); |
162 | 877f6f58 | Adam Menz | deleteContainerTask = new DeleteContainerListenerTask();
|
163 | 877f6f58 | Adam Menz | deleteContainerTask.execute(); |
164 | 877f6f58 | Adam Menz | } |
165 | a7d1fdc2 | Adam Menz | |
166 | 240418be | Phillip Toohill | } |
167 | a7d1fdc2 | Adam Menz | |
168 | a7d1fdc2 | Adam Menz | @Override
|
169 | 802fbd9e | koutsoub | protected void onStop() { |
170 | a7d1fdc2 | Adam Menz | super.onStop();
|
171 | a7d1fdc2 | Adam Menz | |
172 | a7d1fdc2 | Adam Menz | /*
|
173 | 802fbd9e | koutsoub | * Need to stop running listener task if we exit
|
174 | a7d1fdc2 | Adam Menz | */
|
175 | 802fbd9e | koutsoub | if (task != null) { |
176 | a7d1fdc2 | Adam Menz | task.cancel(true);
|
177 | a7d1fdc2 | Adam Menz | } |
178 | 71e52c4a | Adam Menz | |
179 | 802fbd9e | koutsoub | if (deleteObjTask != null) { |
180 | 3e180b04 | Adam Menz | deleteObjTask.cancel(true);
|
181 | 3e180b04 | Adam Menz | } |
182 | 71e52c4a | Adam Menz | |
183 | 802fbd9e | koutsoub | if (deleteContainerTask != null) { |
184 | 3e180b04 | Adam Menz | deleteContainerTask.cancel(true);
|
185 | 3e180b04 | Adam Menz | } |
186 | 3e180b04 | Adam Menz | |
187 | 240418be | Phillip Toohill | } |
188 | 240418be | Phillip Toohill | |
189 | 37a14877 | Adam Menz | /*
|
190 | 37a14877 | Adam Menz | * overriding back button press, because we are not actually changing
|
191 | d3ea294b | Adam Menz | * activities when we navigate the file structure
|
192 | 37a14877 | Adam Menz | */
|
193 | 37a14877 | Adam Menz | public void onBackPressed() { |
194 | cabcecb2 | koutsoub | |
195 | 802fbd9e | koutsoub | if (currentPath.equals("")) { |
196 | cabcecb2 | koutsoub | if(container.getName().equals(Container.MYSHARED)){} |
197 | cabcecb2 | koutsoub | else
|
198 | cabcecb2 | koutsoub | finish(); |
199 | 802fbd9e | koutsoub | } else {
|
200 | 37a14877 | Adam Menz | goUpDirectory(); |
201 | 240418be | Phillip Toohill | } |
202 | 240418be | Phillip Toohill | } |
203 | 05a718db | koutsoub | List<ContainerObjects> previousFiles = new ArrayList<ContainerObjects>(); |
204 | 37a14877 | Adam Menz | /*
|
205 | 37a14877 | Adam Menz | * go to the current directory's parent and display that data
|
206 | 37a14877 | Adam Menz | */
|
207 | 802fbd9e | koutsoub | private void goUpDirectory() { |
208 | 7b27f0dc | koutsoub | if(currentSelectedPath != null){ |
209 | 7b27f0dc | koutsoub | currentSelectedPath=null;
|
210 | 7b27f0dc | koutsoub | loadFiles(); |
211 | 7b27f0dc | koutsoub | return;
|
212 | 7b27f0dc | koutsoub | } |
213 | 802fbd9e | koutsoub | currentPath = currentPath.substring( |
214 | 802fbd9e | koutsoub | 0,
|
215 | 802fbd9e | koutsoub | currentPath.substring(0, currentPath.length() - 2).lastIndexOf( |
216 | 802fbd9e | koutsoub | "/") + 1); |
217 | 7b27f0dc | koutsoub | if(previousFiles!=null&&previousFiles.size()>0){ |
218 | 05a718db | koutsoub | files = previousFiles.toArray(new ContainerObjects[]{}); |
219 | 05a718db | koutsoub | previousFiles=null;
|
220 | 05a718db | koutsoub | loadCurrentDirectoryFiles(); |
221 | 05a718db | koutsoub | displayCurrentFiles(); |
222 | 05a718db | koutsoub | } |
223 | 05a718db | koutsoub | else
|
224 | 05a718db | koutsoub | loadFiles(); |
225 | 05a718db | koutsoub | //now executing new call
|
226 | 05a718db | koutsoub | |
227 | 37a14877 | Adam Menz | } |
228 | 240418be | Phillip Toohill | |
229 | cc71758a | Adam Menz | /*
|
230 | 51938302 | Adam Menz | * load all file that are in the container
|
231 | 51938302 | Adam Menz | */
|
232 | 240418be | Phillip Toohill | private void loadFiles() { |
233 | 802fbd9e | koutsoub | // displayLoadingCell();
|
234 | 05a718db | koutsoub | new LoadFilesTask().execute(currentPath);
|
235 | 37a14877 | Adam Menz | } |
236 | a7d1fdc2 | Adam Menz | |
237 | 802fbd9e | koutsoub | /*
|
238 | 802fbd9e | koutsoub | * load only the files that should display for the current directory in the
|
239 | 802fbd9e | koutsoub | * curDirFiles[]
|
240 | 37a14877 | Adam Menz | */
|
241 | 802fbd9e | koutsoub | protected void loadCurrentDirectoryFiles() { |
242 | 37a14877 | Adam Menz | ArrayList<ContainerObjects> curFiles = new ArrayList<ContainerObjects>(); |
243 | 802fbd9e | koutsoub | Log.i(LOG, "loading files");
|
244 | 802fbd9e | koutsoub | if (files != null) { |
245 | 802fbd9e | koutsoub | for (int i = 0; i < files.length; i++) { |
246 | 802fbd9e | koutsoub | Log.i(LOG, "loading files" + i);
|
247 | 802fbd9e | koutsoub | if (fileBelongsInDir(files[i])) {
|
248 | 37a14877 | Adam Menz | curFiles.add(files[i]); |
249 | 37a14877 | Adam Menz | } |
250 | 37a14877 | Adam Menz | } |
251 | a7d1fdc2 | Adam Menz | app.setCurFiles(curFiles); |
252 | 37a14877 | Adam Menz | } |
253 | 37a14877 | Adam Menz | } |
254 | a7d1fdc2 | Adam Menz | |
255 | 37a14877 | Adam Menz | /*
|
256 | 802fbd9e | koutsoub | * determines if a file should be displayed in current directory
|
257 | 37a14877 | Adam Menz | */
|
258 | 802fbd9e | koutsoub | protected Boolean fileBelongsInDir(ContainerObjects obj) { |
259 | 7b27f0dc | koutsoub | /*String objPath = obj.getCName();
|
260 | 802fbd9e | koutsoub | |
261 | 802fbd9e | koutsoub | if (!objPath.startsWith(currentPath)) {
|
262 | 802fbd9e | koutsoub | Log.i(LOG, "Path is:" + currentPath + " " + objPath + " " + false);
|
263 | 37a14877 | Adam Menz | return false;
|
264 | 802fbd9e | koutsoub | } else {
|
265 | 37a14877 | Adam Menz | objPath = objPath.substring(currentPath.length());
|
266 | 802fbd9e | koutsoub | Log.i(LOG, "Path is:" + currentPath + " " + objPath + " "
|
267 | 802fbd9e | koutsoub | + !objPath.contains("/"));
|
268 | 37a14877 | Adam Menz | return !objPath.contains("/");
|
269 | 7b27f0dc | koutsoub | }*/
|
270 | 7b27f0dc | koutsoub | return true; |
271 | 240418be | Phillip Toohill | } |
272 | 240418be | Phillip Toohill | |
273 | 37a14877 | Adam Menz | /*
|
274 | 802fbd9e | koutsoub | * loads all the files that are in the container into one array
|
275 | 37a14877 | Adam Menz | */
|
276 | 7b27f0dc | koutsoub | private void setFileList(List<ContainerObjects> files) { |
277 | 240418be | Phillip Toohill | if (files == null) { |
278 | 240418be | Phillip Toohill | files = new ArrayList<ContainerObjects>(); |
279 | 240418be | Phillip Toohill | } |
280 | 240418be | Phillip Toohill | String[] fileNames = new String[files.size()]; |
281 | 240418be | Phillip Toohill | this.files = new ContainerObjects[files.size()]; |
282 | 240418be | Phillip Toohill | |
283 | 240418be | Phillip Toohill | if (files != null) { |
284 | 3d6041e8 | Phillip Toohill | for (int i = 0; i < files.size(); i++) { |
285 | 240418be | Phillip Toohill | ContainerObjects file = files.get(i); |
286 | 802fbd9e | koutsoub | // Log.i(file.getCName(),file.getCName());
|
287 | 3d6041e8 | Phillip Toohill | this.files[i] = file;
|
288 | 3d6041e8 | Phillip Toohill | fileNames[i] = file.getName(); |
289 | 3d6041e8 | Phillip Toohill | } |
290 | 3d6041e8 | Phillip Toohill | } |
291 | 37a14877 | Adam Menz | } |
292 | a7d1fdc2 | Adam Menz | |
293 | 802fbd9e | koutsoub | protected void displayCurrentFiles() { |
294 | 94abc2c7 | koutsoub | if(container.getOtherUser()==null) |
295 | 94abc2c7 | koutsoub | setTitle(container.getName()+": /"+currentPath);
|
296 | 94abc2c7 | koutsoub | else
|
297 | 94abc2c7 | koutsoub | setTitle(container.getOtherUser()+":"+container.getName()+"/"+currentPath); |
298 | a7d1fdc2 | Adam Menz | if (app.getCurFiles().size() == 0) { |
299 | a7d1fdc2 | Adam Menz | displayNoFilesCell(); |
300 | 3d6041e8 | Phillip Toohill | } else {
|
301 | 3ea9d68e | Adam Menz | ArrayList<ContainerObjects> tempList = new ArrayList<ContainerObjects>(); |
302 | 802fbd9e | koutsoub | for (int i = 0; i < app.getCurFiles().size(); i++) { |
303 | a7d1fdc2 | Adam Menz | tempList.add(app.getCurFiles().get(i)); |
304 | 3ea9d68e | Adam Menz | } |
305 | a7d1fdc2 | Adam Menz | getListView().setDividerHeight(1); // restore divider lines |
306 | a7d1fdc2 | Adam Menz | setListAdapter(new FileAdapter());
|
307 | 3d6041e8 | Phillip Toohill | } |
308 | 240418be | Phillip Toohill | } |
309 | 240418be | Phillip Toohill | |
310 | 37a14877 | Adam Menz | /*
|
311 | 802fbd9e | koutsoub | * display a different empty page depending of if you are at top of
|
312 | 802fbd9e | koutsoub | * container or in a folder
|
313 | 37a14877 | Adam Menz | */
|
314 | 856ad13d | koutsoub | protected void displayNoFilesCell() { |
315 | 240418be | Phillip Toohill | String a[] = new String[1]; |
316 | 802fbd9e | koutsoub | if (currentPath.equals("")) { |
317 | 37a14877 | Adam Menz | a[0] = "Empty Container"; |
318 | 802fbd9e | koutsoub | setListAdapter(new ArrayAdapter<String>(this, |
319 | 802fbd9e | koutsoub | R.layout.noobjectscell, R.id.no_files_label, a)); |
320 | 802fbd9e | koutsoub | } else {
|
321 | 37a14877 | Adam Menz | a[0] = "No Files"; |
322 | 37a14877 | Adam Menz | setListAdapter(new ArrayAdapter<String>(this, R.layout.nofilescell, |
323 | 71e52c4a | Adam Menz | R.id.no_files_label, a)); |
324 | 37a14877 | Adam Menz | } |
325 | 240418be | Phillip Toohill | getListView().setTextFilterEnabled(true);
|
326 | 240418be | Phillip Toohill | getListView().setDividerHeight(0); // hide the dividers so it won't look |
327 | 71e52c4a | Adam Menz | // like a list row
|
328 | 240418be | Phillip Toohill | getListView().setItemsCanFocus(false);
|
329 | 240418be | Phillip Toohill | } |
330 | a7d1fdc2 | Adam Menz | |
331 | 802fbd9e | koutsoub | /*
|
332 | 802fbd9e | koutsoub | * just get the last part of the filename so the entire file path does not
|
333 | 802fbd9e | koutsoub | * show
|
334 | a7d1fdc2 | Adam Menz | */
|
335 | 802fbd9e | koutsoub | private String getShortName(String longName) { |
336 | c16dc9e7 | Adam Menz | String s = longName;
|
337 | 802fbd9e | koutsoub | if (!s.contains("/")) { |
338 | c16dc9e7 | Adam Menz | return s;
|
339 | 802fbd9e | koutsoub | } else {
|
340 | 802fbd9e | koutsoub | String tmp = s.substring(s.lastIndexOf('/') + 1); |
341 | 802fbd9e | koutsoub | if (tmp.equals("")) { |
342 | 07c153b1 | koutsoub | return s;
|
343 | 07c153b1 | koutsoub | } |
344 | 802fbd9e | koutsoub | return tmp;
|
345 | 3d6041e8 | Phillip Toohill | } |
346 | 240418be | Phillip Toohill | } |
347 | a7d1fdc2 | Adam Menz | |
348 | d3ea294b | Adam Menz | /*
|
349 | 802fbd9e | koutsoub | * removed a specified object from the array of all the files in the
|
350 | 802fbd9e | koutsoub | * container
|
351 | d3ea294b | Adam Menz | */
|
352 | 802fbd9e | koutsoub | private void removeFromList(String path) { |
353 | 802fbd9e | koutsoub | ArrayList<ContainerObjects> temp = new ArrayList<ContainerObjects>( |
354 | 802fbd9e | koutsoub | Arrays.asList(files));
|
355 | 802fbd9e | koutsoub | for (int i = 0; i < files.length; i++) { |
356 | 802fbd9e | koutsoub | if (files[i].getCName()
|
357 | 802fbd9e | koutsoub | .equals(path.substring(0, path.length() - 1))) { |
358 | d3ea294b | Adam Menz | temp.remove(i); |
359 | d3ea294b | Adam Menz | } |
360 | 3d6041e8 | Phillip Toohill | } |
361 | d3ea294b | Adam Menz | files = new ContainerObjects[temp.size()];
|
362 | 802fbd9e | koutsoub | for (int i = 0; i < temp.size(); i++) { |
363 | d3ea294b | Adam Menz | files[i] = temp.get(i); |
364 | d3ea294b | Adam Menz | } |
365 | d3ea294b | Adam Menz | } |
366 | 240418be | Phillip Toohill | |
367 | d3ea294b | Adam Menz | protected void onListItemClick(ListView l, View v, int position, long id) { |
368 | a7d1fdc2 | Adam Menz | if (app.getCurFiles() != null && app.getCurFiles().size() > 0) { |
369 | d3ea294b | Adam Menz | Intent viewIntent; |
370 | 7b27f0dc | koutsoub | if (app.getCurFiles().get(position).isFolder()) {
|
371 | a7d1fdc2 | Adam Menz | currentPath = app.getCurFiles().get(position).getCName() + "/";
|
372 | 7b27f0dc | koutsoub | /*if(container.getName().equalsIgnoreCase(Container.MYSHARED)){
|
373 | 05a718db | koutsoub | loadCurrentDirectoryFiles();
|
374 | 05a718db | koutsoub | displayCurrentFiles();
|
375 | 05a718db | koutsoub | }
|
376 | 7b27f0dc | koutsoub | else{*/
|
377 | 05a718db | koutsoub | previousFiles = Arrays.asList(files);
|
378 | 05a718db | koutsoub | loadFiles(); |
379 | 7b27f0dc | koutsoub | //}
|
380 | 05a718db | koutsoub | //loadCurrentDirectoryFiles();
|
381 | 05a718db | koutsoub | //displayCurrentFiles();
|
382 | d3ea294b | Adam Menz | } |
383 | a7d1fdc2 | Adam Menz | |
384 | 802fbd9e | koutsoub | else {
|
385 | d3ea294b | Adam Menz | viewIntent = new Intent(this, ContainerObjectDetails.class); |
386 | 802fbd9e | koutsoub | viewIntent.putExtra("container", app.getCurFiles()
|
387 | 802fbd9e | koutsoub | .get(position)); |
388 | d3ea294b | Adam Menz | viewIntent.putExtra("cdnUrl", container.getCdnUrl());
|
389 | 94abc2c7 | koutsoub | if(container.getOtherUser()!=null) |
390 | 94abc2c7 | koutsoub | viewIntent.putExtra("otherUser", container.getOtherUser());
|
391 | d3ea294b | Adam Menz | viewIntent.putExtra("containerNames", container.getName());
|
392 | d3ea294b | Adam Menz | viewIntent.putExtra("isCdnEnabled", cdnEnabledIs);
|
393 | 802fbd9e | koutsoub | startActivityForResult(viewIntent, 55); // arbitrary number; |
394 | 802fbd9e | koutsoub | // never
|
395 | d3ea294b | Adam Menz | // used again
|
396 | 6864568a | Phillip Toohill | } |
397 | 3d6041e8 | Phillip Toohill | } |
398 | 240418be | Phillip Toohill | } |
399 | 240418be | Phillip Toohill | |
400 | 240418be | Phillip Toohill | @Override
|
401 | 240418be | Phillip Toohill | public boolean onCreateOptionsMenu(Menu menu) { |
402 | 3d6041e8 | Phillip Toohill | super.onCreateOptionsMenu(menu);
|
403 | 3d6041e8 | Phillip Toohill | MenuInflater inflater = getMenuInflater(); |
404 | 3d6041e8 | Phillip Toohill | inflater.inflate(R.menu.view_container_object_list_menu, menu); |
405 | 05a718db | koutsoub | menu.findItem(R.id.enable_cdn).setVisible(false);
|
406 | 05a718db | koutsoub | if(Container.TRASH.equalsIgnoreCase(container.getName())){ |
407 | 05a718db | koutsoub | menu.findItem(R.id.delete_container).setVisible(false);
|
408 | 05a718db | koutsoub | menu.findItem(R.id.add_folder).setVisible(false);
|
409 | 05a718db | koutsoub | menu.findItem(R.id.add_file).setVisible(false);
|
410 | 05a718db | koutsoub | } |
411 | ecbad159 | koutsoub | else if(Container.MYSHARED.equalsIgnoreCase(container.getName())){ |
412 | ecbad159 | koutsoub | menu.findItem(R.id.delete_container).setVisible(false);
|
413 | ecbad159 | koutsoub | menu.findItem(R.id.add_folder).setVisible(false);
|
414 | ecbad159 | koutsoub | menu.findItem(R.id.add_file).setVisible(false);
|
415 | ecbad159 | koutsoub | } |
416 | 3d6041e8 | Phillip Toohill | return true; |
417 | 240418be | Phillip Toohill | } |
418 | ecbad159 | koutsoub | @Override
|
419 | ecbad159 | koutsoub | public void onCreateContextMenu(ContextMenu menu, View v, |
420 | ecbad159 | koutsoub | ContextMenuInfo menuInfo) { |
421 | ecbad159 | koutsoub | super.onCreateContextMenu(menu, v, menuInfo);
|
422 | ecbad159 | koutsoub | MenuInflater inflater = getMenuInflater(); |
423 | ecbad159 | koutsoub | inflater.inflate(R.menu.view_container_object_list_context, menu); |
424 | ecbad159 | koutsoub | menu.findItem(R.id.fromtrash_contextmenu).setVisible(false);
|
425 | ecbad159 | koutsoub | if(Container.TRASH.equalsIgnoreCase(container.getName())){ |
426 | a2b9aced | koutsoub | menu.findItem(R.id.delete_contextmenu).setVisible(true);
|
427 | ecbad159 | koutsoub | menu.findItem(R.id.totrash_contextmenu).setVisible(false);
|
428 | a2b9aced | koutsoub | menu.findItem(R.id.properties_contextmenu).setVisible(false);
|
429 | ecbad159 | koutsoub | menu.findItem(R.id.fromtrash_contextmenu).setVisible(true);
|
430 | ecbad159 | koutsoub | } |
431 | ecbad159 | koutsoub | else if(Container.MYSHARED.equalsIgnoreCase(container.getName())){ |
432 | ecbad159 | koutsoub | menu.findItem(R.id.delete_contextmenu).setVisible(false);
|
433 | ecbad159 | koutsoub | menu.findItem(R.id.totrash_contextmenu).setVisible(false);
|
434 | ecbad159 | koutsoub | } |
435 | ecbad159 | koutsoub | } |
436 | a2b9aced | koutsoub | ContainerObjects currentSelectedObject=null;
|
437 | ecbad159 | koutsoub | @Override
|
438 | ecbad159 | koutsoub | public boolean onContextItemSelected(final MenuItem item) { |
439 | ecbad159 | koutsoub | final AdapterView.AdapterContextMenuInfo info;
|
440 | ecbad159 | koutsoub | try {
|
441 | ecbad159 | koutsoub | info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); |
442 | ecbad159 | koutsoub | } catch (ClassCastException e) { |
443 | ecbad159 | koutsoub | Log.e(LOG, "bad menuInfo", e);
|
444 | ecbad159 | koutsoub | return false; |
445 | ecbad159 | koutsoub | } |
446 | ecbad159 | koutsoub | long id = getListAdapter().getItemId(info.position);
|
447 | ecbad159 | koutsoub | final ContainerObjects obj = (ContainerObjects) getListAdapter().getItem(info.position);
|
448 | 7b27f0dc | koutsoub | currentSelectedPath = obj.getCName() + "/";
|
449 | a2b9aced | koutsoub | currentSelectedObject=obj; |
450 | ecbad159 | koutsoub | switch (item.getItemId()) {
|
451 | ecbad159 | koutsoub | case R.id.delete_contextmenu:
|
452 | 7b27f0dc | koutsoub | showDialog(deleteContext); |
453 | ecbad159 | koutsoub | return true; |
454 | ecbad159 | koutsoub | case R.id.totrash_contextmenu:
|
455 | 7b27f0dc | koutsoub | showDialog(toTrashContext); |
456 | ecbad159 | koutsoub | return true; |
457 | ecbad159 | koutsoub | case R.id.fromtrash_contextmenu:
|
458 | 7b27f0dc | koutsoub | showDialog(fromTrashContext); |
459 | ecbad159 | koutsoub | return true; |
460 | ecbad159 | koutsoub | case R.id.properties_contextmenu:
|
461 | ecbad159 | koutsoub | Intent viewIntent; |
462 | ecbad159 | koutsoub | viewIntent = new Intent(this, ContainerObjectDetails.class); |
463 | ecbad159 | koutsoub | viewIntent.putExtra("container", obj);
|
464 | ecbad159 | koutsoub | viewIntent.putExtra("cdnUrl", container.getCdnUrl());
|
465 | 94abc2c7 | koutsoub | if(container.getOtherUser()!=null) |
466 | 94abc2c7 | koutsoub | viewIntent.putExtra("otherUser", container.getOtherUser());
|
467 | ecbad159 | koutsoub | viewIntent.putExtra("containerNames", container.getName());
|
468 | ecbad159 | koutsoub | viewIntent.putExtra("isCdnEnabled", cdnEnabledIs);
|
469 | ecbad159 | koutsoub | startActivityForResult(viewIntent, 55);
|
470 | ecbad159 | koutsoub | return true; |
471 | ecbad159 | koutsoub | |
472 | ecbad159 | koutsoub | } |
473 | 7b27f0dc | koutsoub | currentSelectedPath=null;
|
474 | a2b9aced | koutsoub | currentSelectedObject=null;
|
475 | ecbad159 | koutsoub | return false; |
476 | ecbad159 | koutsoub | |
477 | ecbad159 | koutsoub | } |
478 | 240418be | Phillip Toohill | @Override
|
479 | 37a14877 | Adam Menz | /*
|
480 | 802fbd9e | koutsoub | * option performed for delete depends on if you are at the top of a
|
481 | 802fbd9e | koutsoub | * container or in a folder
|
482 | 37a14877 | Adam Menz | */
|
483 | 240418be | Phillip Toohill | public boolean onOptionsItemSelected(MenuItem item) { |
484 | 3d6041e8 | Phillip Toohill | switch (item.getItemId()) {
|
485 | 3d6041e8 | Phillip Toohill | case R.id.delete_container:
|
486 | 802fbd9e | koutsoub | if (currentPath.equals("")) { |
487 | 37a14877 | Adam Menz | showDialog(deleteContainer); |
488 | 802fbd9e | koutsoub | } else {
|
489 | 37a14877 | Adam Menz | showDialog(deleteFolder); |
490 | 37a14877 | Adam Menz | } |
491 | 3d6041e8 | Phillip Toohill | return true; |
492 | 3d6041e8 | Phillip Toohill | case R.id.enable_cdn:
|
493 | 3d6041e8 | Phillip Toohill | Intent viewIntent1 = new Intent(this, EnableCDNActivity.class); |
494 | 240418be | Phillip Toohill | viewIntent1.putExtra("Cname", container.getName());
|
495 | 240418be | Phillip Toohill | startActivityForResult(viewIntent1, 56);
|
496 | 3d6041e8 | Phillip Toohill | return true; |
497 | 3d6041e8 | Phillip Toohill | case R.id.refresh:
|
498 | 3d6041e8 | Phillip Toohill | loadFiles(); |
499 | 240418be | Phillip Toohill | return true; |
500 | d3ea294b | Adam Menz | case R.id.add_folder:
|
501 | d3ea294b | Adam Menz | showDialog(R.id.add_folder); |
502 | 44ac7bea | Adam Menz | return true; |
503 | d3ea294b | Adam Menz | case R.id.add_file:
|
504 | 802fbd9e | koutsoub | /*
|
505 | 802fbd9e | koutsoub | * Intent viewIntent2 = new Intent(this, AddFileActivity.class);
|
506 | 802fbd9e | koutsoub | * viewIntent2.putExtra("Cname", container.getName());
|
507 | 802fbd9e | koutsoub | * viewIntent2.putExtra("curPath", currentPath);
|
508 | 802fbd9e | koutsoub | * startActivityForResult(viewIntent2, 56);
|
509 | 802fbd9e | koutsoub | */
|
510 | 802fbd9e | koutsoub | |
511 | 802fbd9e | koutsoub | Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
|
512 | 802fbd9e | koutsoub | intent.addCategory(Intent.CATEGORY_OPENABLE); |
513 | 802fbd9e | koutsoub | intent.setData(Uri.parse("file://"));
|
514 | 802fbd9e | koutsoub | intent.setType("*/*");
|
515 | 802fbd9e | koutsoub | try {
|
516 | 802fbd9e | koutsoub | int i = 1; |
517 | 802fbd9e | koutsoub | startActivityForResult(intent, i); |
518 | 802fbd9e | koutsoub | |
519 | 802fbd9e | koutsoub | } catch (ActivityNotFoundException e) {
|
520 | 802fbd9e | koutsoub | Toast.makeText(this, "No File Manager", Toast.LENGTH_SHORT) |
521 | 802fbd9e | koutsoub | .show(); |
522 | 802fbd9e | koutsoub | } |
523 | 802fbd9e | koutsoub | |
524 | 802fbd9e | koutsoub | return true; |
525 | 3d6041e8 | Phillip Toohill | } |
526 | 3d6041e8 | Phillip Toohill | return false; |
527 | 240418be | Phillip Toohill | } |
528 | 240418be | Phillip Toohill | |
529 | 3d6041e8 | Phillip Toohill | @Override
|
530 | 240418be | Phillip Toohill | protected Dialog onCreateDialog(int id) { |
531 | 240418be | Phillip Toohill | switch (id) {
|
532 | 240418be | Phillip Toohill | case deleteContainer:
|
533 | 802fbd9e | koutsoub | if (app.getCurFiles().size() == 0) { |
534 | 37a14877 | Adam Menz | return new AlertDialog.Builder(ContainerObjectsActivity.this) |
535 | 802fbd9e | koutsoub | .setIcon(R.drawable.alert_dialog_icon) |
536 | 802fbd9e | koutsoub | .setTitle("Delete Container")
|
537 | 802fbd9e | koutsoub | .setMessage( |
538 | 802fbd9e | koutsoub | "Are you sure you want to delete this Container?")
|
539 | 802fbd9e | koutsoub | .setPositiveButton("Delete Container",
|
540 | 802fbd9e | koutsoub | new DialogInterface.OnClickListener() {
|
541 | 802fbd9e | koutsoub | public void onClick(DialogInterface dialog, |
542 | 802fbd9e | koutsoub | int whichButton) {
|
543 | 802fbd9e | koutsoub | // User clicked OK so do some stuff
|
544 | 802fbd9e | koutsoub | trackEvent( |
545 | 802fbd9e | koutsoub | GoogleAnalytics.CATEGORY_CONTAINER, |
546 | 802fbd9e | koutsoub | GoogleAnalytics.EVENT_DELETE, |
547 | 802fbd9e | koutsoub | "", -1); |
548 | 802fbd9e | koutsoub | new DeleteContainerTask()
|
549 | 802fbd9e | koutsoub | .execute(currentPath); |
550 | 802fbd9e | koutsoub | } |
551 | 802fbd9e | koutsoub | }) |
552 | 802fbd9e | koutsoub | .setNegativeButton("Cancel",
|
553 | 802fbd9e | koutsoub | new DialogInterface.OnClickListener() {
|
554 | 802fbd9e | koutsoub | public void onClick(DialogInterface dialog, |
555 | 802fbd9e | koutsoub | int whichButton) {
|
556 | 802fbd9e | koutsoub | // User clicked Cancel so do some stuff
|
557 | 802fbd9e | koutsoub | } |
558 | 802fbd9e | koutsoub | }).create(); |
559 | 802fbd9e | koutsoub | } else {
|
560 | 37a14877 | Adam Menz | return new AlertDialog.Builder(ContainerObjectsActivity.this) |
561 | 802fbd9e | koutsoub | .setIcon(R.drawable.alert_dialog_icon) |
562 | 802fbd9e | koutsoub | .setTitle("Delete Container")
|
563 | 802fbd9e | koutsoub | .setMessage("Container must be empty to delete")
|
564 | 802fbd9e | koutsoub | .setNegativeButton("OK",
|
565 | 802fbd9e | koutsoub | new DialogInterface.OnClickListener() {
|
566 | 802fbd9e | koutsoub | public void onClick(DialogInterface dialog, |
567 | 802fbd9e | koutsoub | int whichButton) {
|
568 | 802fbd9e | koutsoub | // User clicked Cancel so do some stuff
|
569 | 802fbd9e | koutsoub | } |
570 | 802fbd9e | koutsoub | }).create(); |
571 | 37a14877 | Adam Menz | } |
572 | 37a14877 | Adam Menz | case deleteFolder:
|
573 | 802fbd9e | koutsoub | if (app.getCurFiles().size() == 0) { |
574 | 37a14877 | Adam Menz | return new AlertDialog.Builder(ContainerObjectsActivity.this) |
575 | 802fbd9e | koutsoub | .setIcon(R.drawable.alert_dialog_icon) |
576 | 802fbd9e | koutsoub | .setTitle("Delete Folder")
|
577 | 802fbd9e | koutsoub | .setMessage( |
578 | 802fbd9e | koutsoub | "Are you sure you want to delete this Folder?")
|
579 | 802fbd9e | koutsoub | .setPositiveButton("Delete Folder",
|
580 | 802fbd9e | koutsoub | new DialogInterface.OnClickListener() {
|
581 | 802fbd9e | koutsoub | public void onClick(DialogInterface dialog, |
582 | 802fbd9e | koutsoub | int whichButton) {
|
583 | 802fbd9e | koutsoub | // User clicked OK so do some stuff
|
584 | d2e9a932 | koutsoub | new DeleteObjectTask().execute(container.getName(), currentPath);
|
585 | 802fbd9e | koutsoub | } |
586 | 802fbd9e | koutsoub | }) |
587 | 802fbd9e | koutsoub | .setNegativeButton("Cancel",
|
588 | 802fbd9e | koutsoub | new DialogInterface.OnClickListener() {
|
589 | 802fbd9e | koutsoub | public void onClick(DialogInterface dialog, |
590 | 802fbd9e | koutsoub | int whichButton) {
|
591 | 802fbd9e | koutsoub | // User clicked Cancel so do some stuff
|
592 | 802fbd9e | koutsoub | } |
593 | 802fbd9e | koutsoub | }).create(); |
594 | 37a14877 | Adam Menz | } |
595 | 7b27f0dc | koutsoub | case deleteContext:
|
596 | 7b27f0dc | koutsoub | return new AlertDialog.Builder(ContainerObjectsActivity.this) |
597 | 7b27f0dc | koutsoub | .setIcon(R.drawable.alert_dialog_icon) |
598 | 7b27f0dc | koutsoub | .setTitle("Delete Object")
|
599 | 7b27f0dc | koutsoub | .setMessage( |
600 | 7b27f0dc | koutsoub | "Are you sure you want to delete this Object?")
|
601 | 7b27f0dc | koutsoub | .setPositiveButton("Delete Object",
|
602 | 7b27f0dc | koutsoub | new DialogInterface.OnClickListener() {
|
603 | 7b27f0dc | koutsoub | public void onClick(DialogInterface dialog, |
604 | 7b27f0dc | koutsoub | int whichButton) {
|
605 | 7b27f0dc | koutsoub | // User clicked OK so do some stuff
|
606 | 7b27f0dc | koutsoub | new DeleteObjectTask().execute(container.getName(), currentSelectedPath);
|
607 | 7b27f0dc | koutsoub | } |
608 | 7b27f0dc | koutsoub | }) |
609 | 7b27f0dc | koutsoub | .setNegativeButton("Cancel",
|
610 | 7b27f0dc | koutsoub | new DialogInterface.OnClickListener() {
|
611 | 7b27f0dc | koutsoub | public void onClick(DialogInterface dialog, |
612 | 7b27f0dc | koutsoub | int whichButton) {
|
613 | 7b27f0dc | koutsoub | currentSelectedPath=null;
|
614 | 7b27f0dc | koutsoub | // User clicked Cancel so do some stuff
|
615 | 7b27f0dc | koutsoub | } |
616 | 7b27f0dc | koutsoub | }).create(); |
617 | a2b9aced | koutsoub | case toTrashContext:
|
618 | a2b9aced | koutsoub | return new AlertDialog.Builder(ContainerObjectsActivity.this) |
619 | a2b9aced | koutsoub | .setIcon(R.drawable.alert_dialog_icon) |
620 | a2b9aced | koutsoub | .setTitle("Move Object To Trash")
|
621 | a2b9aced | koutsoub | .setMessage( |
622 | a2b9aced | koutsoub | "Are you sure you want to trash this Object?")
|
623 | a2b9aced | koutsoub | .setPositiveButton("Trash Object",
|
624 | a2b9aced | koutsoub | new DialogInterface.OnClickListener() {
|
625 | a2b9aced | koutsoub | public void onClick(DialogInterface dialog, |
626 | a2b9aced | koutsoub | int whichButton) {
|
627 | a2b9aced | koutsoub | // User clicked OK so do some stuff
|
628 | a2b9aced | koutsoub | new TrashObjectTask().execute(container.getName(), currentSelectedPath);
|
629 | a2b9aced | koutsoub | } |
630 | a2b9aced | koutsoub | }) |
631 | a2b9aced | koutsoub | .setNegativeButton("Cancel",
|
632 | a2b9aced | koutsoub | new DialogInterface.OnClickListener() {
|
633 | a2b9aced | koutsoub | public void onClick(DialogInterface dialog, |
634 | a2b9aced | koutsoub | int whichButton) {
|
635 | a2b9aced | koutsoub | currentSelectedPath=null;
|
636 | a2b9aced | koutsoub | // User clicked Cancel so do some stuff
|
637 | a2b9aced | koutsoub | } |
638 | a2b9aced | koutsoub | }).create(); |
639 | a2b9aced | koutsoub | case fromTrashContext:
|
640 | a2b9aced | koutsoub | return new AlertDialog.Builder(ContainerObjectsActivity.this) |
641 | a2b9aced | koutsoub | .setIcon(R.drawable.alert_dialog_icon) |
642 | a2b9aced | koutsoub | .setTitle("Restore Object To Pithos")
|
643 | a2b9aced | koutsoub | .setMessage( |
644 | a2b9aced | koutsoub | "Are you sure you want to restore this Object?")
|
645 | a2b9aced | koutsoub | .setPositiveButton("Restore Object",
|
646 | a2b9aced | koutsoub | new DialogInterface.OnClickListener() {
|
647 | a2b9aced | koutsoub | public void onClick(DialogInterface dialog, |
648 | a2b9aced | koutsoub | int whichButton) {
|
649 | a2b9aced | koutsoub | // User clicked OK so do some stuff
|
650 | a2b9aced | koutsoub | new RestoreTrashObjectTask().execute(container.getName(), currentSelectedPath);
|
651 | a2b9aced | koutsoub | } |
652 | a2b9aced | koutsoub | }) |
653 | a2b9aced | koutsoub | .setNegativeButton("Cancel",
|
654 | a2b9aced | koutsoub | new DialogInterface.OnClickListener() {
|
655 | a2b9aced | koutsoub | public void onClick(DialogInterface dialog, |
656 | a2b9aced | koutsoub | int whichButton) {
|
657 | a2b9aced | koutsoub | currentSelectedPath=null;
|
658 | a2b9aced | koutsoub | // User clicked Cancel so do some stuff
|
659 | a2b9aced | koutsoub | } |
660 | a2b9aced | koutsoub | }).create(); |
661 | d3ea294b | Adam Menz | case R.id.add_folder:
|
662 | d3ea294b | Adam Menz | final EditText input = new EditText(this); |
663 | a7d1fdc2 | Adam Menz | return new AlertDialog.Builder(ContainerObjectsActivity.this) |
664 | 802fbd9e | koutsoub | .setIcon(R.drawable.alert_dialog_icon) |
665 | 802fbd9e | koutsoub | .setView(input) |
666 | 802fbd9e | koutsoub | .setTitle("Add Folder")
|
667 | 802fbd9e | koutsoub | .setMessage("Enter new name for folder: ")
|
668 | 802fbd9e | koutsoub | .setPositiveButton("Add",
|
669 | 802fbd9e | koutsoub | new DialogInterface.OnClickListener() {
|
670 | 802fbd9e | koutsoub | public void onClick(DialogInterface dialog, |
671 | 802fbd9e | koutsoub | int whichButton) {
|
672 | 802fbd9e | koutsoub | // User clicked OK so do some stuff
|
673 | 802fbd9e | koutsoub | String[] info = { |
674 | 802fbd9e | koutsoub | input.getText().toString(), |
675 | 802fbd9e | koutsoub | "application/directory" };
|
676 | 802fbd9e | koutsoub | new AddFolderTask().execute(info);
|
677 | 802fbd9e | koutsoub | } |
678 | 802fbd9e | koutsoub | }) |
679 | 802fbd9e | koutsoub | .setNegativeButton("Cancel",
|
680 | 802fbd9e | koutsoub | new DialogInterface.OnClickListener() {
|
681 | 802fbd9e | koutsoub | public void onClick(DialogInterface dialog, |
682 | 802fbd9e | koutsoub | int whichButton) {
|
683 | 802fbd9e | koutsoub | // User clicked Cancel so do some stuff
|
684 | 802fbd9e | koutsoub | } |
685 | 802fbd9e | koutsoub | }).create(); |
686 | 240418be | Phillip Toohill | } |
687 | 240418be | Phillip Toohill | return null; |
688 | 3d6041e8 | Phillip Toohill | } |
689 | 3d6041e8 | Phillip Toohill | |
690 | 240418be | Phillip Toohill | @Override
|
691 | 240418be | Phillip Toohill | public void onActivityResult(int requestCode, int resultCode, Intent data) { |
692 | 240418be | Phillip Toohill | super.onActivityResult(requestCode, resultCode, data);
|
693 | 71e52c4a | Adam Menz | |
694 | e6c34a0f | Adam Menz | if (resultCode == RESULT_OK && requestCode == 56) { |
695 | 240418be | Phillip Toohill | // a sub-activity kicked back, so we want to refresh the server list
|
696 | d2e9a932 | koutsoub | previousFiles = null;
|
697 | 240418be | Phillip Toohill | loadFiles(); |
698 | 240418be | Phillip Toohill | } |
699 | 802fbd9e | koutsoub | |
700 | 802fbd9e | koutsoub | if (resultCode == RESULT_OK && requestCode == 1) { |
701 | 802fbd9e | koutsoub | String filename = data.getDataString();
|
702 | 802fbd9e | koutsoub | uploadFile(filename, data); |
703 | 802fbd9e | koutsoub | |
704 | 802fbd9e | koutsoub | } |
705 | 71e52c4a | Adam Menz | |
706 | 3e180b04 | Adam Menz | // deleted file so need to update the list
|
707 | 3e180b04 | Adam Menz | if (requestCode == 55 && resultCode == 99) { |
708 | d2e9a932 | koutsoub | Log.d(LOG,"LOADING FROM DDELETE");
|
709 | d2e9a932 | koutsoub | previousFiles = null;
|
710 | 3e180b04 | Adam Menz | loadFiles(); |
711 | 240418be | Phillip Toohill | } |
712 | a7d1fdc2 | Adam Menz | |
713 | 32731215 | Adam Menz | } |
714 | a7d1fdc2 | Adam Menz | |
715 | d3ea294b | Adam Menz | class FileAdapter extends ArrayAdapter<ContainerObjects> { |
716 | d3ea294b | Adam Menz | FileAdapter() { |
717 | d3ea294b | Adam Menz | super(ContainerObjectsActivity.this,
|
718 | 802fbd9e | koutsoub | R.layout.listcontainerobjectcell, app.getCurFiles()); |
719 | d3ea294b | Adam Menz | } |
720 | a7d1fdc2 | Adam Menz | |
721 | d3ea294b | Adam Menz | public View getView(int position, View convertView, ViewGroup parent) { |
722 | a7d1fdc2 | Adam Menz | ContainerObjects file = app.getCurFiles().get(position); |
723 | d3ea294b | Adam Menz | LayoutInflater inflater = getLayoutInflater(); |
724 | d3ea294b | Adam Menz | View row = inflater.inflate(R.layout.listcontainerobjectcell,
|
725 | d3ea294b | Adam Menz | parent, false);
|
726 | a7d1fdc2 | Adam Menz | |
727 | d3ea294b | Adam Menz | TextView label = (TextView) row.findViewById(R.id.label); |
728 | d3ea294b | Adam Menz | label.setText(getShortName(file.getCName())); |
729 | a7d1fdc2 | Adam Menz | |
730 | 802fbd9e | koutsoub | ImageView objectImage = (ImageView) row |
731 | 802fbd9e | koutsoub | .findViewById(R.id.file_type_image); |
732 | 7b27f0dc | koutsoub | if (file.isFolder()) {
|
733 | f506786e | Adam Menz | objectImage.setImageResource(R.drawable.folder); |
734 | f506786e | Adam Menz | } else {
|
735 | f506786e | Adam Menz | objectImage.setImageResource(R.drawable.file); |
736 | f506786e | Adam Menz | } |
737 | 802fbd9e | koutsoub | |
738 | d3ea294b | Adam Menz | if (file.getBytes() >= bConver) {
|
739 | d3ea294b | Adam Menz | megaBytes = Math.abs(file.getBytes() / bConver + 0.2); |
740 | d3ea294b | Adam Menz | TextView sublabel = (TextView) row.findViewById(R.id.sublabel); |
741 | d3ea294b | Adam Menz | sublabel.setText(megaBytes + " MB");
|
742 | d3ea294b | Adam Menz | } else if (file.getBytes() >= kbConver) { |
743 | d3ea294b | Adam Menz | kiloBytes = Math.abs(file.getBytes() / kbConver + 0.2); |
744 | d3ea294b | Adam Menz | TextView sublabel = (TextView) row.findViewById(R.id.sublabel); |
745 | d3ea294b | Adam Menz | sublabel.setText(kiloBytes + " KB");
|
746 | d3ea294b | Adam Menz | } else {
|
747 | d3ea294b | Adam Menz | TextView sublabel = (TextView) row.findViewById(R.id.sublabel); |
748 | d3ea294b | Adam Menz | sublabel.setText(file.getBytes() + " B");
|
749 | d3ea294b | Adam Menz | } |
750 | a7d1fdc2 | Adam Menz | |
751 | d3ea294b | Adam Menz | return (row);
|
752 | d3ea294b | Adam Menz | } |
753 | d3ea294b | Adam Menz | } |
754 | 71e52c4a | Adam Menz | |
755 | d3ea294b | Adam Menz | private class LoadFilesTask extends |
756 | 7b27f0dc | koutsoub | AsyncTask<String, Void, List<ContainerObjects>> { |
757 | 240418be | Phillip Toohill | |
758 | 3d6041e8 | Phillip Toohill | private CloudServersException exception;
|
759 | 71e52c4a | Adam Menz | |
760 | 802fbd9e | koutsoub | protected void onPreExecute() { |
761 | a7d1fdc2 | Adam Menz | showDialog(); |
762 | b2a2d2f1 | Adam Menz | loadingFiles = true;
|
763 | d3ea294b | Adam Menz | } |
764 | a7d1fdc2 | Adam Menz | |
765 | d3ea294b | Adam Menz | @Override
|
766 | 7b27f0dc | koutsoub | protected List<ContainerObjects> doInBackground(String... path) { |
767 | 7b27f0dc | koutsoub | List<ContainerObjects> files = null; |
768 | d3ea294b | Adam Menz | try {
|
769 | 802fbd9e | koutsoub | if (container.getName().equals(Container.MYSHARED)) { |
770 | 802fbd9e | koutsoub | files = (new ContainerObjectManager(getContext()))
|
771 | 7b27f0dc | koutsoub | .createListMyShared( container.getName(), |
772 | 802fbd9e | koutsoub | new ContainerManager(getContext())
|
773 | 7b27f0dc | koutsoub | .createList(true),path[0]); |
774 | 802fbd9e | koutsoub | } else if (container.getName().equals(Container.OTHERS)) { |
775 | 802fbd9e | koutsoub | |
776 | 802fbd9e | koutsoub | } else {
|
777 | 802fbd9e | koutsoub | if (container.getOtherUser() == null) |
778 | 802fbd9e | koutsoub | files = (new ContainerObjectManager(getContext()))
|
779 | 7b27f0dc | koutsoub | .createList(container.getName(), path[0]);
|
780 | 856ad13d | koutsoub | else
|
781 | 802fbd9e | koutsoub | files = (new ContainerObjectManager(getContext()))
|
782 | 94abc2c7 | koutsoub | .createOtherList(container.getName(), container.getOtherUser(),path[0]);
|
783 | 856ad13d | koutsoub | } |
784 | d3ea294b | Adam Menz | } catch (CloudServersException e) {
|
785 | d3ea294b | Adam Menz | exception = e; |
786 | d3ea294b | Adam Menz | e.printStackTrace(); |
787 | d3ea294b | Adam Menz | } |
788 | d3ea294b | Adam Menz | return files;
|
789 | d3ea294b | Adam Menz | } |
790 | a7d1fdc2 | Adam Menz | |
791 | d3ea294b | Adam Menz | @Override
|
792 | 7b27f0dc | koutsoub | protected void onPostExecute(List<ContainerObjects> result) { |
793 | b2a2d2f1 | Adam Menz | loadingFiles = false;
|
794 | a7d1fdc2 | Adam Menz | hideDialog(); |
795 | d3ea294b | Adam Menz | if (exception != null) { |
796 | d3ea294b | Adam Menz | showAlert("Error", exception.getMessage());
|
797 | d3ea294b | Adam Menz | } |
798 | d3ea294b | Adam Menz | setFileList(result); |
799 | 3ea9d68e | Adam Menz | loadCurrentDirectoryFiles(); |
800 | 3ea9d68e | Adam Menz | displayCurrentFiles(); |
801 | d3ea294b | Adam Menz | } |
802 | 51938302 | Adam Menz | |
803 | d3ea294b | Adam Menz | } |
804 | d3ea294b | Adam Menz | |
805 | 802fbd9e | koutsoub | private class AddFolderTask extends AsyncTask<String, Void, HttpBundle> { |
806 | 802fbd9e | koutsoub | |
807 | 802fbd9e | koutsoub | private CloudServersException exception;
|
808 | 802fbd9e | koutsoub | |
809 | 802fbd9e | koutsoub | @Override
|
810 | 802fbd9e | koutsoub | protected void onPreExecute() { |
811 | 802fbd9e | koutsoub | showDialog(); |
812 | 802fbd9e | koutsoub | app.setAddingObject(true);
|
813 | 802fbd9e | koutsoub | task = new AddObjectListenerTask();
|
814 | 802fbd9e | koutsoub | task.execute(); |
815 | 802fbd9e | koutsoub | } |
816 | 802fbd9e | koutsoub | |
817 | 802fbd9e | koutsoub | @Override
|
818 | 802fbd9e | koutsoub | protected HttpBundle doInBackground(String... data) { |
819 | 802fbd9e | koutsoub | HttpBundle bundle = null;
|
820 | 802fbd9e | koutsoub | try {
|
821 | 802fbd9e | koutsoub | |
822 | 802fbd9e | koutsoub | bundle = (new ContainerObjectManager(getContext())).addObject(
|
823 | fc8b1f79 | koutsoub | container.getName(), currentPath, data[0], data[1],container.getOtherUser()); |
824 | 802fbd9e | koutsoub | } catch (CloudServersException e) {
|
825 | 802fbd9e | koutsoub | exception = e; |
826 | 802fbd9e | koutsoub | } |
827 | 802fbd9e | koutsoub | return bundle;
|
828 | 802fbd9e | koutsoub | } |
829 | 802fbd9e | koutsoub | |
830 | 802fbd9e | koutsoub | @Override
|
831 | 802fbd9e | koutsoub | protected void onPostExecute(HttpBundle bundle) { |
832 | 802fbd9e | koutsoub | app.setAddingObject(false);
|
833 | 802fbd9e | koutsoub | hideDialog(); |
834 | 802fbd9e | koutsoub | HttpResponse response = bundle.getResponse(); |
835 | 802fbd9e | koutsoub | if (response != null) { |
836 | 802fbd9e | koutsoub | int statusCode = response.getStatusLine().getStatusCode();
|
837 | 802fbd9e | koutsoub | if (statusCode == 201) { |
838 | 802fbd9e | koutsoub | setResult(Activity.RESULT_OK); |
839 | 802fbd9e | koutsoub | // loading the new files is done by ListenerTask
|
840 | 802fbd9e | koutsoub | } else {
|
841 | 802fbd9e | koutsoub | CloudServersException cse = parseCloudServersException(response); |
842 | 802fbd9e | koutsoub | if ("".equals(cse.getMessage())) { |
843 | 802fbd9e | koutsoub | showError("There was a problem deleting your folder.",
|
844 | 802fbd9e | koutsoub | bundle); |
845 | 802fbd9e | koutsoub | } else {
|
846 | 802fbd9e | koutsoub | showError("There was a problem deleting your folder: "
|
847 | 802fbd9e | koutsoub | + cse.getMessage(), bundle); |
848 | 802fbd9e | koutsoub | } |
849 | 802fbd9e | koutsoub | } |
850 | 802fbd9e | koutsoub | } else if (exception != null) { |
851 | 802fbd9e | koutsoub | showError("There was a problem deleting your folder: "
|
852 | 802fbd9e | koutsoub | + exception.getMessage(), bundle); |
853 | 802fbd9e | koutsoub | } |
854 | 802fbd9e | koutsoub | } |
855 | 802fbd9e | koutsoub | } |
856 | 802fbd9e | koutsoub | |
857 | 802fbd9e | koutsoub | private class AddFileTask extends AsyncTask<String, Void, HttpBundle> { |
858 | 3d6041e8 | Phillip Toohill | |
859 | 3d6041e8 | Phillip Toohill | private CloudServersException exception;
|
860 | a7d1fdc2 | Adam Menz | |
861 | a7d1fdc2 | Adam Menz | @Override
|
862 | 802fbd9e | koutsoub | protected void onPreExecute() { |
863 | a7d1fdc2 | Adam Menz | showDialog(); |
864 | a7d1fdc2 | Adam Menz | app.setAddingObject(true);
|
865 | a7d1fdc2 | Adam Menz | task = new AddObjectListenerTask();
|
866 | a7d1fdc2 | Adam Menz | task.execute(); |
867 | d3ea294b | Adam Menz | } |
868 | a7d1fdc2 | Adam Menz | |
869 | 3d6041e8 | Phillip Toohill | @Override
|
870 | a7d1fdc2 | Adam Menz | protected HttpBundle doInBackground(String... data) { |
871 | 32731215 | Adam Menz | HttpBundle bundle = null;
|
872 | 3d6041e8 | Phillip Toohill | try {
|
873 | 71e52c4a | Adam Menz | |
874 | 802fbd9e | koutsoub | bundle = (new ContainerObjectManager(getContext())).addFileObject(
|
875 | fc8b1f79 | koutsoub | container.getName(), currentPath, data[0], data[1], data[2], container.getOtherUser()); |
876 | 3d6041e8 | Phillip Toohill | } catch (CloudServersException e) {
|
877 | 3d6041e8 | Phillip Toohill | exception = e; |
878 | 3d6041e8 | Phillip Toohill | } |
879 | 32731215 | Adam Menz | return bundle;
|
880 | 3d6041e8 | Phillip Toohill | } |
881 | 240418be | Phillip Toohill | |
882 | 3d6041e8 | Phillip Toohill | @Override
|
883 | 32731215 | Adam Menz | protected void onPostExecute(HttpBundle bundle) { |
884 | a7d1fdc2 | Adam Menz | app.setAddingObject(false);
|
885 | b2a2d2f1 | Adam Menz | hideDialog(); |
886 | 32731215 | Adam Menz | HttpResponse response = bundle.getResponse(); |
887 | 3d6041e8 | Phillip Toohill | if (response != null) { |
888 | 3d6041e8 | Phillip Toohill | int statusCode = response.getStatusLine().getStatusCode();
|
889 | a7d1fdc2 | Adam Menz | if (statusCode == 201) { |
890 | 37a14877 | Adam Menz | setResult(Activity.RESULT_OK); |
891 | 802fbd9e | koutsoub | // loading the new files is done by ListenerTask
|
892 | 37a14877 | Adam Menz | } else {
|
893 | 37a14877 | Adam Menz | CloudServersException cse = parseCloudServersException(response); |
894 | 37a14877 | Adam Menz | if ("".equals(cse.getMessage())) { |
895 | 802fbd9e | koutsoub | showError("There was a problem deleting your folder.",
|
896 | 802fbd9e | koutsoub | bundle); |
897 | 37a14877 | Adam Menz | } else {
|
898 | b2a2d2f1 | Adam Menz | showError("There was a problem deleting your folder: "
|
899 | a7d1fdc2 | Adam Menz | + cse.getMessage(), bundle); |
900 | 37a14877 | Adam Menz | } |
901 | 37a14877 | Adam Menz | } |
902 | 37a14877 | Adam Menz | } else if (exception != null) { |
903 | b2a2d2f1 | Adam Menz | showError("There was a problem deleting your folder: "
|
904 | 32731215 | Adam Menz | + exception.getMessage(), bundle); |
905 | 37a14877 | Adam Menz | } |
906 | 37a14877 | Adam Menz | } |
907 | 37a14877 | Adam Menz | } |
908 | a7d1fdc2 | Adam Menz | |
909 | d2e9a932 | koutsoub | private class DeleteObjectTask extends AsyncTask<String, Void, HttpBundle> { |
910 | 71e52c4a | Adam Menz | |
911 | d3ea294b | Adam Menz | private CloudServersException exception;
|
912 | 7b27f0dc | koutsoub | public boolean isInFile=false; |
913 | d3ea294b | Adam Menz | @Override
|
914 | 802fbd9e | koutsoub | protected void onPreExecute() { |
915 | a7d1fdc2 | Adam Menz | showDialog(); |
916 | a7d1fdc2 | Adam Menz | app.setDeleteingObject(true);
|
917 | a7d1fdc2 | Adam Menz | deleteObjTask = new DeleteObjectListenerTask();
|
918 | a7d1fdc2 | Adam Menz | deleteObjTask.execute(); |
919 | a7d1fdc2 | Adam Menz | } |
920 | 71e52c4a | Adam Menz | |
921 | a7d1fdc2 | Adam Menz | @Override
|
922 | d2e9a932 | koutsoub | protected HttpBundle doInBackground(String... args) { |
923 | 32731215 | Adam Menz | HttpBundle bundle = null;
|
924 | d3ea294b | Adam Menz | try {
|
925 | 802fbd9e | koutsoub | // subtring because the current directory contains a "/" at the
|
926 | 802fbd9e | koutsoub | // end of the string
|
927 | d2e9a932 | koutsoub | String cname = args[0]; |
928 | d2e9a932 | koutsoub | String cpath = args[1]; |
929 | 802fbd9e | koutsoub | bundle = (new ContainerObjectManager(getContext()))
|
930 | d2e9a932 | koutsoub | .deleteObject(cname, cpath |
931 | fc8b1f79 | koutsoub | .substring(0, cpath.length() - 1),container.getOtherUser()); |
932 | d3ea294b | Adam Menz | } catch (CloudServersException e) {
|
933 | d3ea294b | Adam Menz | exception = e; |
934 | d3ea294b | Adam Menz | } |
935 | 32731215 | Adam Menz | return bundle;
|
936 | d3ea294b | Adam Menz | } |
937 | 71e52c4a | Adam Menz | |
938 | d3ea294b | Adam Menz | @Override
|
939 | 32731215 | Adam Menz | protected void onPostExecute(HttpBundle bundle) { |
940 | a7d1fdc2 | Adam Menz | app.setDeleteingObject(false);
|
941 | b2a2d2f1 | Adam Menz | hideDialog(); |
942 | 32731215 | Adam Menz | HttpResponse response = bundle.getResponse(); |
943 | d3ea294b | Adam Menz | if (response != null) { |
944 | d3ea294b | Adam Menz | int statusCode = response.getStatusLine().getStatusCode();
|
945 | a7d1fdc2 | Adam Menz | if (statusCode == 409) { |
946 | a7d1fdc2 | Adam Menz | showAlert("Error",
|
947 | 802fbd9e | koutsoub | "Folder must be empty in order to delete");
|
948 | a7d1fdc2 | Adam Menz | } |
949 | a7d1fdc2 | Adam Menz | if (statusCode == 204) { |
950 | d3ea294b | Adam Menz | setResult(Activity.RESULT_OK); |
951 | 3e180b04 | Adam Menz | } else {
|
952 | d3ea294b | Adam Menz | CloudServersException cse = parseCloudServersException(response); |
953 | d3ea294b | Adam Menz | if ("".equals(cse.getMessage())) { |
954 | 802fbd9e | koutsoub | showError("There was a problem deleting your folder.",
|
955 | 802fbd9e | koutsoub | bundle); |
956 | d3ea294b | Adam Menz | } else {
|
957 | b2a2d2f1 | Adam Menz | showError("There was a problem deleting your folder: "
|
958 | a7d1fdc2 | Adam Menz | + cse.getMessage(), bundle); |
959 | d3ea294b | Adam Menz | } |
960 | d3ea294b | Adam Menz | } |
961 | d3ea294b | Adam Menz | } else if (exception != null) { |
962 | b2a2d2f1 | Adam Menz | showError("There was a problem deleting your folder: "
|
963 | 32731215 | Adam Menz | + exception.getMessage(), bundle); |
964 | a2b9aced | koutsoub | } |
965 | a2b9aced | koutsoub | } |
966 | a2b9aced | koutsoub | } |
967 | a2b9aced | koutsoub | |
968 | a2b9aced | koutsoub | private class TrashObjectTask extends AsyncTask<String, Void, HttpBundle> { |
969 | a2b9aced | koutsoub | |
970 | a2b9aced | koutsoub | private CloudServersException exception;
|
971 | a2b9aced | koutsoub | public boolean isInFile=false; |
972 | a2b9aced | koutsoub | String[] arguments; |
973 | a2b9aced | koutsoub | @Override
|
974 | a2b9aced | koutsoub | protected void onPreExecute() { |
975 | a2b9aced | koutsoub | showDialog(); |
976 | a2b9aced | koutsoub | |
977 | a2b9aced | koutsoub | } |
978 | a2b9aced | koutsoub | |
979 | a2b9aced | koutsoub | @Override
|
980 | a2b9aced | koutsoub | protected HttpBundle doInBackground(String... args) { |
981 | a2b9aced | koutsoub | HttpBundle bundle = null;
|
982 | a2b9aced | koutsoub | arguments = args; |
983 | a2b9aced | koutsoub | try {
|
984 | a2b9aced | koutsoub | // subtring because the current directory contains a "/" at the
|
985 | a2b9aced | koutsoub | // end of the string
|
986 | a2b9aced | koutsoub | String cname = args[0]; |
987 | a2b9aced | koutsoub | String cpath = args[1]; |
988 | a2b9aced | koutsoub | bundle = (new ContainerObjectManager(getContext()))
|
989 | a2b9aced | koutsoub | .trashObject(cname, cpath |
990 | a2b9aced | koutsoub | .substring(0, cpath.length() - 1)); |
991 | a2b9aced | koutsoub | } catch (CloudServersException e) {
|
992 | a2b9aced | koutsoub | exception = e; |
993 | a2b9aced | koutsoub | } |
994 | a2b9aced | koutsoub | return bundle;
|
995 | a2b9aced | koutsoub | } |
996 | a2b9aced | koutsoub | |
997 | a2b9aced | koutsoub | @Override
|
998 | a2b9aced | koutsoub | protected void onPostExecute(HttpBundle bundle) { |
999 | a2b9aced | koutsoub | hideDialog(); |
1000 | a2b9aced | koutsoub | HttpResponse response = bundle.getResponse(); |
1001 | a2b9aced | koutsoub | if (response != null) { |
1002 | a2b9aced | koutsoub | int statusCode = response.getStatusLine().getStatusCode();
|
1003 | a2b9aced | koutsoub | if (statusCode == 409) { |
1004 | a2b9aced | koutsoub | showAlert("Error",
|
1005 | a2b9aced | koutsoub | "Folder must be empty in order to delete");
|
1006 | a2b9aced | koutsoub | } |
1007 | a2b9aced | koutsoub | if (statusCode == 201) { |
1008 | a2b9aced | koutsoub | new DeleteObjectTask().execute(arguments);
|
1009 | a2b9aced | koutsoub | } else {
|
1010 | a2b9aced | koutsoub | CloudServersException cse = parseCloudServersException(response); |
1011 | a2b9aced | koutsoub | if ("".equals(cse.getMessage())) { |
1012 | a2b9aced | koutsoub | showError("There was a problem deleting your folder.",
|
1013 | a2b9aced | koutsoub | bundle); |
1014 | a2b9aced | koutsoub | } else {
|
1015 | a2b9aced | koutsoub | showError("There was a problem deleting your folder: "
|
1016 | a2b9aced | koutsoub | + cse.getMessage(), bundle); |
1017 | a2b9aced | koutsoub | } |
1018 | a2b9aced | koutsoub | } |
1019 | a2b9aced | koutsoub | } else if (exception != null) { |
1020 | a2b9aced | koutsoub | showError("There was a problem deleting your folder: "
|
1021 | a2b9aced | koutsoub | + exception.getMessage(), bundle); |
1022 | a2b9aced | koutsoub | } |
1023 | a2b9aced | koutsoub | } |
1024 | a2b9aced | koutsoub | } |
1025 | a2b9aced | koutsoub | |
1026 | a2b9aced | koutsoub | private class RestoreTrashObjectTask extends AsyncTask<String, Void, HttpBundle> { |
1027 | a2b9aced | koutsoub | |
1028 | a2b9aced | koutsoub | private CloudServersException exception;
|
1029 | a2b9aced | koutsoub | public boolean isInFile=false; |
1030 | a2b9aced | koutsoub | String[] arguments; |
1031 | a2b9aced | koutsoub | @Override
|
1032 | a2b9aced | koutsoub | protected void onPreExecute() { |
1033 | a2b9aced | koutsoub | showDialog(); |
1034 | a2b9aced | koutsoub | |
1035 | a2b9aced | koutsoub | } |
1036 | a2b9aced | koutsoub | |
1037 | a2b9aced | koutsoub | @Override
|
1038 | a2b9aced | koutsoub | protected HttpBundle doInBackground(String... args) { |
1039 | a2b9aced | koutsoub | HttpBundle bundle = null;
|
1040 | a2b9aced | koutsoub | arguments = args; |
1041 | a2b9aced | koutsoub | try {
|
1042 | a2b9aced | koutsoub | // subtring because the current directory contains a "/" at the
|
1043 | a2b9aced | koutsoub | // end of the string
|
1044 | a2b9aced | koutsoub | String cname = args[0]; |
1045 | a2b9aced | koutsoub | String cpath = args[1]; |
1046 | a2b9aced | koutsoub | bundle = (new ContainerObjectManager(getContext()))
|
1047 | a2b9aced | koutsoub | .restoreObject(cname, cpath |
1048 | a2b9aced | koutsoub | .substring(0, cpath.length() - 1)); |
1049 | a2b9aced | koutsoub | } catch (CloudServersException e) {
|
1050 | a2b9aced | koutsoub | exception = e; |
1051 | a2b9aced | koutsoub | } |
1052 | a2b9aced | koutsoub | return bundle;
|
1053 | a2b9aced | koutsoub | } |
1054 | a2b9aced | koutsoub | |
1055 | a2b9aced | koutsoub | @Override
|
1056 | a2b9aced | koutsoub | protected void onPostExecute(HttpBundle bundle) { |
1057 | a2b9aced | koutsoub | hideDialog(); |
1058 | a2b9aced | koutsoub | HttpResponse response = bundle.getResponse(); |
1059 | a2b9aced | koutsoub | if (response != null) { |
1060 | a2b9aced | koutsoub | int statusCode = response.getStatusLine().getStatusCode();
|
1061 | a2b9aced | koutsoub | if (statusCode == 409) { |
1062 | a2b9aced | koutsoub | showAlert("Error",
|
1063 | a2b9aced | koutsoub | "Folder must be empty in order to delete");
|
1064 | a2b9aced | koutsoub | } |
1065 | a2b9aced | koutsoub | if (statusCode == 201) { |
1066 | a2b9aced | koutsoub | new DeleteObjectTask().execute(arguments);
|
1067 | a2b9aced | koutsoub | } else {
|
1068 | a2b9aced | koutsoub | CloudServersException cse = parseCloudServersException(response); |
1069 | a2b9aced | koutsoub | if ("".equals(cse.getMessage())) { |
1070 | a2b9aced | koutsoub | showError("There was a problem deleting your folder.",
|
1071 | a2b9aced | koutsoub | bundle); |
1072 | a2b9aced | koutsoub | } else {
|
1073 | a2b9aced | koutsoub | showError("There was a problem deleting your folder: "
|
1074 | a2b9aced | koutsoub | + cse.getMessage(), bundle); |
1075 | a2b9aced | koutsoub | } |
1076 | a2b9aced | koutsoub | } |
1077 | a2b9aced | koutsoub | } else if (exception != null) { |
1078 | a2b9aced | koutsoub | showError("There was a problem deleting your folder: "
|
1079 | a2b9aced | koutsoub | + exception.getMessage(), bundle); |
1080 | d3ea294b | Adam Menz | } |
1081 | d3ea294b | Adam Menz | } |
1082 | d3ea294b | Adam Menz | } |
1083 | d3ea294b | Adam Menz | |
1084 | 37a14877 | Adam Menz | private class DeleteContainerTask extends |
1085 | 802fbd9e | koutsoub | AsyncTask<String, Void, HttpBundle> { |
1086 | 37a14877 | Adam Menz | |
1087 | 37a14877 | Adam Menz | private CloudServersException exception;
|
1088 | 37a14877 | Adam Menz | |
1089 | 37a14877 | Adam Menz | @Override
|
1090 | 802fbd9e | koutsoub | protected void onPreExecute() { |
1091 | a7d1fdc2 | Adam Menz | showDialog(); |
1092 | a7d1fdc2 | Adam Menz | app.setDeletingContainer(true);
|
1093 | a7d1fdc2 | Adam Menz | deleteContainerTask = new DeleteContainerListenerTask();
|
1094 | a7d1fdc2 | Adam Menz | deleteContainerTask.execute(); |
1095 | a7d1fdc2 | Adam Menz | } |
1096 | 71e52c4a | Adam Menz | |
1097 | a7d1fdc2 | Adam Menz | @Override
|
1098 | 32731215 | Adam Menz | protected HttpBundle doInBackground(String... object) { |
1099 | 32731215 | Adam Menz | HttpBundle bundle = null;
|
1100 | 37a14877 | Adam Menz | try {
|
1101 | 802fbd9e | koutsoub | bundle = (new ContainerManager(getContext())).delete(container
|
1102 | 802fbd9e | koutsoub | .getName()); |
1103 | 3d6041e8 | Phillip Toohill | } catch (CloudServersException e) {
|
1104 | 3d6041e8 | Phillip Toohill | exception = e; |
1105 | 3d6041e8 | Phillip Toohill | } |
1106 | 32731215 | Adam Menz | return bundle;
|
1107 | 3d6041e8 | Phillip Toohill | } |
1108 | 240418be | Phillip Toohill | |
1109 | 3d6041e8 | Phillip Toohill | @Override
|
1110 | 32731215 | Adam Menz | protected void onPostExecute(HttpBundle bundle) { |
1111 | a7d1fdc2 | Adam Menz | hideDialog(); |
1112 | a7d1fdc2 | Adam Menz | app.setDeletingContainer(false);
|
1113 | 32731215 | Adam Menz | HttpResponse response = bundle.getResponse(); |
1114 | 3d6041e8 | Phillip Toohill | if (response != null) { |
1115 | 3d6041e8 | Phillip Toohill | int statusCode = response.getStatusLine().getStatusCode();
|
1116 | 3d6041e8 | Phillip Toohill | if (statusCode == 409) { |
1117 | 802fbd9e | koutsoub | showError("Container must be empty in order to delete",
|
1118 | 802fbd9e | koutsoub | bundle); |
1119 | 3d6041e8 | Phillip Toohill | } |
1120 | 3d6041e8 | Phillip Toohill | if (statusCode == 204) { |
1121 | 3d6041e8 | Phillip Toohill | setResult(Activity.RESULT_OK); |
1122 | 240418be | Phillip Toohill | |
1123 | 3d6041e8 | Phillip Toohill | } else {
|
1124 | 3d6041e8 | Phillip Toohill | CloudServersException cse = parseCloudServersException(response); |
1125 | 3d6041e8 | Phillip Toohill | if ("".equals(cse.getMessage())) { |
1126 | 802fbd9e | koutsoub | showError( |
1127 | 802fbd9e | koutsoub | "There was a problem deleting your container.",
|
1128 | 802fbd9e | koutsoub | bundle); |
1129 | 3d6041e8 | Phillip Toohill | } else {
|
1130 | 802fbd9e | koutsoub | showError( |
1131 | 802fbd9e | koutsoub | "There was a problem deleting your container: "
|
1132 | 802fbd9e | koutsoub | + cse.getMessage(), bundle); |
1133 | 3d6041e8 | Phillip Toohill | } |
1134 | 3d6041e8 | Phillip Toohill | } |
1135 | 3d6041e8 | Phillip Toohill | } else if (exception != null) { |
1136 | b2a2d2f1 | Adam Menz | showError("There was a problem deleting your server: "
|
1137 | 32731215 | Adam Menz | + exception.getMessage(), bundle); |
1138 | 240418be | Phillip Toohill | } |
1139 | 3d6041e8 | Phillip Toohill | } |
1140 | 240418be | Phillip Toohill | } |
1141 | 3d6041e8 | Phillip Toohill | |
1142 | a7d1fdc2 | Adam Menz | /*
|
1143 | 802fbd9e | koutsoub | * listens for the application to change isProcessing listens so activity
|
1144 | 802fbd9e | koutsoub | * knows when it should display the new curDirFiles
|
1145 | a7d1fdc2 | Adam Menz | */
|
1146 | 802fbd9e | koutsoub | private class AddObjectListenerTask extends AsyncTask<Void, Void, Void> { |
1147 | 71e52c4a | Adam Menz | |
1148 | a7d1fdc2 | Adam Menz | @Override
|
1149 | a7d1fdc2 | Adam Menz | protected Void doInBackground(Void... arg1) { |
1150 | a7d1fdc2 | Adam Menz | |
1151 | 802fbd9e | koutsoub | while (app.isAddingObject()) {
|
1152 | a7d1fdc2 | Adam Menz | // wait for process to finish
|
1153 | a7d1fdc2 | Adam Menz | // or have it be canceled
|
1154 | 802fbd9e | koutsoub | if (task.isCancelled()) {
|
1155 | a7d1fdc2 | Adam Menz | return null; |
1156 | a7d1fdc2 | Adam Menz | } |
1157 | a7d1fdc2 | Adam Menz | } |
1158 | a7d1fdc2 | Adam Menz | return null; |
1159 | a7d1fdc2 | Adam Menz | } |
1160 | a7d1fdc2 | Adam Menz | |
1161 | a7d1fdc2 | Adam Menz | /*
|
1162 | 802fbd9e | koutsoub | * when no longer processing, time to load the new files
|
1163 | a7d1fdc2 | Adam Menz | */
|
1164 | a7d1fdc2 | Adam Menz | @Override
|
1165 | a7d1fdc2 | Adam Menz | protected void onPostExecute(Void arg1) { |
1166 | b2a2d2f1 | Adam Menz | hideDialog(); |
1167 | a7d1fdc2 | Adam Menz | loadFiles(); |
1168 | a7d1fdc2 | Adam Menz | } |
1169 | a7d1fdc2 | Adam Menz | } |
1170 | 71e52c4a | Adam Menz | |
1171 | 802fbd9e | koutsoub | private class DeleteObjectListenerTask extends AsyncTask<Void, Void, Void> { |
1172 | 71e52c4a | Adam Menz | |
1173 | a7d1fdc2 | Adam Menz | @Override
|
1174 | a7d1fdc2 | Adam Menz | protected Void doInBackground(Void... arg1) { |
1175 | a7d1fdc2 | Adam Menz | |
1176 | 802fbd9e | koutsoub | while (app.isDeletingObject()) {
|
1177 | a7d1fdc2 | Adam Menz | // wait for process to finish
|
1178 | a7d1fdc2 | Adam Menz | // or have it be canceled
|
1179 | 802fbd9e | koutsoub | if (deleteObjTask.isCancelled()) {
|
1180 | a7d1fdc2 | Adam Menz | return null; |
1181 | a7d1fdc2 | Adam Menz | } |
1182 | a7d1fdc2 | Adam Menz | } |
1183 | a7d1fdc2 | Adam Menz | return null; |
1184 | a7d1fdc2 | Adam Menz | } |
1185 | a7d1fdc2 | Adam Menz | |
1186 | a7d1fdc2 | Adam Menz | /*
|
1187 | 802fbd9e | koutsoub | * when no longer processing, time to load the new files
|
1188 | a7d1fdc2 | Adam Menz | */
|
1189 | a7d1fdc2 | Adam Menz | @Override
|
1190 | a7d1fdc2 | Adam Menz | protected void onPostExecute(Void arg1) { |
1191 | a7d1fdc2 | Adam Menz | hideDialog(); |
1192 | 7b27f0dc | koutsoub | if(currentSelectedPath==null) |
1193 | 7b27f0dc | koutsoub | removeFromList(currentPath); |
1194 | d2e9a932 | koutsoub | previousFiles=null;
|
1195 | a7d1fdc2 | Adam Menz | goUpDirectory(); |
1196 | a7d1fdc2 | Adam Menz | } |
1197 | a7d1fdc2 | Adam Menz | } |
1198 | 71e52c4a | Adam Menz | |
1199 | a7d1fdc2 | Adam Menz | private class DeleteContainerListenerTask extends |
1200 | 802fbd9e | koutsoub | AsyncTask<Void, Void, Void> { |
1201 | 71e52c4a | Adam Menz | |
1202 | a7d1fdc2 | Adam Menz | @Override
|
1203 | a7d1fdc2 | Adam Menz | protected Void doInBackground(Void... arg1) { |
1204 | a7d1fdc2 | Adam Menz | |
1205 | 802fbd9e | koutsoub | while (app.isDeletingContainer()) {
|
1206 | a7d1fdc2 | Adam Menz | // wait for process to finish
|
1207 | a7d1fdc2 | Adam Menz | // or have it be canceled
|
1208 | 802fbd9e | koutsoub | if (deleteContainerTask.isCancelled()) {
|
1209 | a7d1fdc2 | Adam Menz | return null; |
1210 | a7d1fdc2 | Adam Menz | } |
1211 | a7d1fdc2 | Adam Menz | } |
1212 | a7d1fdc2 | Adam Menz | return null; |
1213 | a7d1fdc2 | Adam Menz | } |
1214 | a7d1fdc2 | Adam Menz | |
1215 | a7d1fdc2 | Adam Menz | /*
|
1216 | 802fbd9e | koutsoub | * when no longer processing, time to load the new files
|
1217 | a7d1fdc2 | Adam Menz | */
|
1218 | a7d1fdc2 | Adam Menz | @Override
|
1219 | a7d1fdc2 | Adam Menz | protected void onPostExecute(Void arg1) { |
1220 | 877f6f58 | Adam Menz | |
1221 | 877f6f58 | Adam Menz | hideDialog(); |
1222 | a06c1add | Adam Menz | setResult(RESULT_OK); |
1223 | a7d1fdc2 | Adam Menz | finish(); |
1224 | a7d1fdc2 | Adam Menz | } |
1225 | a7d1fdc2 | Adam Menz | } |
1226 | 802fbd9e | koutsoub | |
1227 | 856ad13d | koutsoub | public String getCurrentPath() { |
1228 | 856ad13d | koutsoub | return currentPath;
|
1229 | 856ad13d | koutsoub | } |
1230 | 802fbd9e | koutsoub | |
1231 | 856ad13d | koutsoub | public ContainerObjects[] getFiles() { |
1232 | 856ad13d | koutsoub | return files;
|
1233 | 856ad13d | koutsoub | } |
1234 | 802fbd9e | koutsoub | |
1235 | 802fbd9e | koutsoub | /***** UPLOAD FILE ****/
|
1236 | 802fbd9e | koutsoub | protected void uploadFile(String filename, Intent data){ |
1237 | 802fbd9e | koutsoub | if (filename.startsWith("file://")) { |
1238 | 802fbd9e | koutsoub | filename = filename.substring(7);
|
1239 | 802fbd9e | koutsoub | } |
1240 | 802fbd9e | koutsoub | // replace %20 and so on
|
1241 | 802fbd9e | koutsoub | filename = Uri.decode(filename); |
1242 | 802fbd9e | koutsoub | |
1243 | 802fbd9e | koutsoub | int indx = filename.lastIndexOf("//"); |
1244 | 802fbd9e | koutsoub | File file = new File(data.getData().getPath()); |
1245 | 802fbd9e | koutsoub | String filenameNew = null; |
1246 | 802fbd9e | koutsoub | Long fileSize = null; |
1247 | 802fbd9e | koutsoub | if (!file.exists()) {
|
1248 | 802fbd9e | koutsoub | Cursor cursor = getContentResolver().query(data.getData(), null, null, null, null); |
1249 | 802fbd9e | koutsoub | if (cursor != null) { |
1250 | 802fbd9e | koutsoub | while (cursor.moveToNext()) {
|
1251 | 802fbd9e | koutsoub | for (int i = 0; i < cursor.getColumnCount(); i++) { |
1252 | 802fbd9e | koutsoub | if (cursor.getColumnName(i).equals("_data")) |
1253 | 802fbd9e | koutsoub | filenameNew = cursor.getString(i); |
1254 | 802fbd9e | koutsoub | if (cursor.getColumnName(i).equals("_size")) |
1255 | 802fbd9e | koutsoub | fileSize = cursor.getLong(i); |
1256 | 802fbd9e | koutsoub | } |
1257 | 802fbd9e | koutsoub | } |
1258 | 802fbd9e | koutsoub | } |
1259 | 802fbd9e | koutsoub | } else {
|
1260 | 802fbd9e | koutsoub | filenameNew = data.getData().getPath(); |
1261 | 802fbd9e | koutsoub | } |
1262 | 802fbd9e | koutsoub | if (filenameNew != null) { |
1263 | 802fbd9e | koutsoub | file = new File(filenameNew); |
1264 | 802fbd9e | koutsoub | String ext = MimeTypeMap.getSingleton().getFileExtensionFromUrl(file.getPath());
|
1265 | 802fbd9e | koutsoub | String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(ext);
|
1266 | 802fbd9e | koutsoub | String[] info = { |
1267 | 802fbd9e | koutsoub | file.getName(), |
1268 | 802fbd9e | koutsoub | mime, filenameNew}; |
1269 | 802fbd9e | koutsoub | new AddFileTask().execute(info);
|
1270 | 802fbd9e | koutsoub | //getTasks().getUploadTask(GssMyFolders.this).execute(getCurrentResource().getUri() + URLEncoder.encode(file.getName()), filenameNew);
|
1271 | 802fbd9e | koutsoub | } |
1272 | 802fbd9e | koutsoub | } |
1273 | 802fbd9e | koutsoub | |
1274 | 802fbd9e | koutsoub | protected void uploadFile(List<Uri> uris){ |
1275 | 802fbd9e | koutsoub | List<String> strings = new ArrayList<String>(); |
1276 | 802fbd9e | koutsoub | String path = "";//getCurrentResource().getUri(); |
1277 | 802fbd9e | koutsoub | if(!path.endsWith("/")) |
1278 | 802fbd9e | koutsoub | path = path+"/";
|
1279 | 802fbd9e | koutsoub | |
1280 | 802fbd9e | koutsoub | for(Uri data : uris){
|
1281 | 802fbd9e | koutsoub | String filename = data.getPath();
|
1282 | 802fbd9e | koutsoub | if (filename.startsWith("file://")) { |
1283 | 802fbd9e | koutsoub | filename = filename.substring(7);
|
1284 | 802fbd9e | koutsoub | } |
1285 | 802fbd9e | koutsoub | // replace %20 and so on
|
1286 | 802fbd9e | koutsoub | filename = Uri.decode(filename); |
1287 | 802fbd9e | koutsoub | |
1288 | 802fbd9e | koutsoub | int indx = filename.lastIndexOf("//"); |
1289 | 802fbd9e | koutsoub | File file = new File(filename); |
1290 | 802fbd9e | koutsoub | String filenameNew = null; |
1291 | 802fbd9e | koutsoub | Long fileSize = null; |
1292 | 802fbd9e | koutsoub | if (!file.exists()) {
|
1293 | 802fbd9e | koutsoub | Cursor cursor = getContentResolver().query(data, null, null, null, null); |
1294 | 802fbd9e | koutsoub | if (cursor != null) { |
1295 | 802fbd9e | koutsoub | while (cursor.moveToNext()) {
|
1296 | 802fbd9e | koutsoub | for (int i = 0; i < cursor.getColumnCount(); i++) { |
1297 | 802fbd9e | koutsoub | if (cursor.getColumnName(i).equals("_data")) |
1298 | 802fbd9e | koutsoub | filenameNew = cursor.getString(i); |
1299 | 802fbd9e | koutsoub | if (cursor.getColumnName(i).equals("_size")) |
1300 | 802fbd9e | koutsoub | fileSize = cursor.getLong(i); |
1301 | 802fbd9e | koutsoub | } |
1302 | 802fbd9e | koutsoub | } |
1303 | 802fbd9e | koutsoub | } |
1304 | 802fbd9e | koutsoub | } else {
|
1305 | 802fbd9e | koutsoub | filenameNew = data.getPath(); |
1306 | 802fbd9e | koutsoub | } |
1307 | 802fbd9e | koutsoub | if (filenameNew != null) { |
1308 | 802fbd9e | koutsoub | file = new File(filenameNew); |
1309 | 802fbd9e | koutsoub | strings.add(path+URLEncoder.encode(file.getName()));
|
1310 | 802fbd9e | koutsoub | strings.add(filenameNew); |
1311 | 802fbd9e | koutsoub | } |
1312 | 802fbd9e | koutsoub | } |
1313 | 802fbd9e | koutsoub | Log.i("*******",""+strings.size()); |
1314 | 802fbd9e | koutsoub | //getTasks().getMultiUploadTask(this).execute(strings.toArray(new String[strings.size()]));
|
1315 | 802fbd9e | koutsoub | |
1316 | 802fbd9e | koutsoub | |
1317 | 802fbd9e | koutsoub | } |
1318 | 802fbd9e | koutsoub | protected void uploadFile(Uri data){ |
1319 | 802fbd9e | koutsoub | String filename = data.getPath();
|
1320 | 802fbd9e | koutsoub | if (filename.startsWith("file://")) { |
1321 | 802fbd9e | koutsoub | filename = filename.substring(7);
|
1322 | 802fbd9e | koutsoub | } |
1323 | 802fbd9e | koutsoub | // replace %20 and so on
|
1324 | 802fbd9e | koutsoub | filename = Uri.decode(filename); |
1325 | 802fbd9e | koutsoub | |
1326 | 802fbd9e | koutsoub | int indx = filename.lastIndexOf("//"); |
1327 | 802fbd9e | koutsoub | File file = new File(filename); |
1328 | 802fbd9e | koutsoub | String filenameNew = null; |
1329 | 802fbd9e | koutsoub | Long fileSize = null; |
1330 | 802fbd9e | koutsoub | if (!file.exists()) {
|
1331 | 802fbd9e | koutsoub | Cursor cursor = getContentResolver().query(data, null, null, null, null); |
1332 | 802fbd9e | koutsoub | if (cursor != null) { |
1333 | 802fbd9e | koutsoub | while (cursor.moveToNext()) {
|
1334 | 802fbd9e | koutsoub | for (int i = 0; i < cursor.getColumnCount(); i++) { |
1335 | 802fbd9e | koutsoub | if (cursor.getColumnName(i).equals("_data")) |
1336 | 802fbd9e | koutsoub | filenameNew = cursor.getString(i); |
1337 | 802fbd9e | koutsoub | if (cursor.getColumnName(i).equals("_size")) |
1338 | 802fbd9e | koutsoub | fileSize = cursor.getLong(i); |
1339 | 802fbd9e | koutsoub | } |
1340 | 802fbd9e | koutsoub | } |
1341 | 802fbd9e | koutsoub | } |
1342 | 802fbd9e | koutsoub | } else {
|
1343 | 802fbd9e | koutsoub | filenameNew = data.getPath(); |
1344 | 802fbd9e | koutsoub | } |
1345 | 802fbd9e | koutsoub | if (filenameNew != null) { |
1346 | 802fbd9e | koutsoub | file = new File(filenameNew); |
1347 | 802fbd9e | koutsoub | //String path = getCurrentResource().getUri();
|
1348 | 802fbd9e | koutsoub | //if(!path.endsWith("/"))
|
1349 | 802fbd9e | koutsoub | //path = path+"/";
|
1350 | 802fbd9e | koutsoub | //getTasks().getUploadTask(GssMyFolders.this).execute(path + URLEncoder.encode(file.getName()), filenameNew);
|
1351 | 802fbd9e | koutsoub | } |
1352 | 802fbd9e | koutsoub | |
1353 | 802fbd9e | koutsoub | } |
1354 | 3d6041e8 | Phillip Toohill | } |