Added dynamic update of files list while full synchronization is performed
[pub/Android/ownCloud.git] / src / eu / alefzero / owncloud / ui / activity / FileDisplayActivity.java
1 /* ownCloud Android client application
2 * Copyright (C) 2011 Bartek Przybylski
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 */
18
19 package eu.alefzero.owncloud.ui.activity;
20
21 import java.io.File;
22 import java.util.ArrayList;
23
24 import android.accounts.Account;
25 import android.accounts.AccountManager;
26 import android.app.AlertDialog;
27 import android.app.AlertDialog.Builder;
28 import android.app.Dialog;
29 import android.content.BroadcastReceiver;
30 import android.content.ContentResolver;
31 import android.content.Context;
32 import android.content.DialogInterface;
33 import android.content.DialogInterface.OnClickListener;
34 import android.content.Intent;
35 import android.content.IntentFilter;
36 import android.content.pm.PackageInfo;
37 import android.content.pm.PackageManager.NameNotFoundException;
38 import android.database.Cursor;
39 import android.net.Uri;
40 import android.os.Bundle;
41 import android.provider.MediaStore;
42 import android.util.Log;
43 import android.view.View;
44 import android.view.ViewGroup;
45 import android.widget.ArrayAdapter;
46 import android.widget.EditText;
47 import android.widget.TextView;
48 import android.widget.Toast;
49
50 import com.actionbarsherlock.app.ActionBar;
51 import com.actionbarsherlock.app.ActionBar.OnNavigationListener;
52 import com.actionbarsherlock.app.SherlockFragmentActivity;
53 import com.actionbarsherlock.view.Menu;
54 import com.actionbarsherlock.view.MenuInflater;
55 import com.actionbarsherlock.view.MenuItem;
56 import com.actionbarsherlock.view.Window;
57
58 import eu.alefzero.owncloud.AccountUtils;
59 import eu.alefzero.owncloud.CrashHandler;
60 import eu.alefzero.owncloud.R;
61 import eu.alefzero.owncloud.authenticator.AccountAuthenticator;
62 import eu.alefzero.owncloud.datamodel.DataStorageManager;
63 import eu.alefzero.owncloud.datamodel.FileDataStorageManager;
64 import eu.alefzero.owncloud.datamodel.OCFile;
65 import eu.alefzero.owncloud.files.services.FileDownloader;
66 import eu.alefzero.owncloud.files.services.FileUploader;
67 import eu.alefzero.owncloud.syncadapter.FileSyncService;
68 import eu.alefzero.owncloud.ui.fragment.FileDetailFragment;
69 import eu.alefzero.owncloud.ui.fragment.FileListFragment;
70 import eu.alefzero.webdav.WebdavClient;
71
72 /**
73 * Displays, what files the user has available in his ownCloud.
74 *
75 * @author Bartek Przybylski
76 *
77 */
78
79 public class FileDisplayActivity extends SherlockFragmentActivity implements
80 OnNavigationListener, OnClickListener, android.view.View.OnClickListener {
81
82 private ArrayAdapter<String> mDirectories;
83 private OCFile mCurrentDir;
84 private String[] mDirs = null;
85
86 private DataStorageManager mStorageManager;
87 private SyncBroadcastReceiver mSyncBroadcastReceiver;
88 private UploadFinishReceiver mUploadFinishReceiver;
89
90 private View mLayoutView = null;
91 private FileListFragment mFileList;
92
93 private static final String KEY_DIR_ARRAY = "DIR_ARRAY";
94 private static final String KEY_CURRENT_DIR = "DIR";
95
96 private static final int DIALOG_SETUP_ACCOUNT = 0;
97 private static final int DIALOG_CREATE_DIR = 1;
98 private static final int DIALOG_ABOUT_APP = 2;
99
100 private static final int ACTION_SELECT_FILE = 1;
101 //private static final int ACTION_CREATE_FIRST_ACCOUNT = 2; dvelasco: WIP
102
103 @Override
104 public void onCreate(Bundle savedInstanceState) {
105 Log.i(getClass().toString(), "onCreate() start");
106 super.onCreate(savedInstanceState);
107
108 requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
109 setSupportProgressBarIndeterminateVisibility(false);
110
111 Thread.setDefaultUncaughtExceptionHandler(new CrashHandler(getApplicationContext()));
112
113 if(savedInstanceState != null){
114 mCurrentDir = (OCFile) savedInstanceState.getParcelable(KEY_CURRENT_DIR); // this is never saved with this key :S
115 }
116
117 mLayoutView = getLayoutInflater().inflate(R.layout.files, null); // always inflate this at onCreate() ; just once!
118
119 if (AccountUtils.accountsAreSetup(this)) {
120 setContentView(mLayoutView);
121
122 } else {
123 setContentView(R.layout.no_account_available);
124 setProgressBarIndeterminateVisibility(false);
125 getSupportActionBar().setNavigationMode(ActionBar.DISPLAY_SHOW_TITLE);
126 findViewById(R.id.setup_account).setOnClickListener(this);
127 }
128
129 Log.i(getClass().toString(), "onCreate() end");
130 }
131
132 @Override
133 public boolean onCreateOptionsMenu(Menu menu) {
134 MenuInflater inflater = getSherlock().getMenuInflater();
135 inflater.inflate(R.menu.menu, menu);
136 return true;
137 }
138
139 @Override
140 public boolean onOptionsItemSelected(MenuItem item) {
141 boolean retval = true;
142 switch (item.getItemId()) {
143 case R.id.createDirectoryItem: {
144 showDialog(DIALOG_CREATE_DIR);
145 break;
146 }
147 case R.id.startSync: {
148 Bundle bundle = new Bundle();
149 bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
150 bundle.putString("PROBANDO", "PARAMETRO PASADO AL SYNC");
151 ContentResolver.requestSync(
152 AccountUtils.getCurrentOwnCloudAccount(this),
153 "org.owncloud", bundle);
154 break;
155 }
156 case R.id.action_upload: {
157 Intent action = new Intent(Intent.ACTION_GET_CONTENT);
158 action = action.setType("*/*")
159 .addCategory(Intent.CATEGORY_OPENABLE);
160 startActivityForResult(
161 Intent.createChooser(action, "Upload file from..."),
162 ACTION_SELECT_FILE);
163 break;
164 }
165 case R.id.action_settings: {
166 Intent settingsIntent = new Intent(this, Preferences.class);
167 startActivity(settingsIntent);
168 break;
169 }
170 case R.id.about_app : {
171 showDialog(DIALOG_ABOUT_APP);
172 break;
173 }
174 case android.R.id.home: {
175 if(mCurrentDir != null && mCurrentDir.getParentId() != 0){
176 onBackPressed();
177 }
178 break;
179 }
180 default:
181 retval = false;
182 }
183 return retval;
184 }
185
186 @Override
187 public boolean onNavigationItemSelected(int itemPosition, long itemId) {
188 int i = itemPosition;
189 while (i-- != 0) {
190 onBackPressed();
191 }
192 return true;
193 }
194
195 /**
196 * Called, when the user selected something for uploading
197 */
198 public void onActivityResult(int requestCode, int resultCode, Intent data) {
199 if (requestCode == ACTION_SELECT_FILE) {
200 if (resultCode == RESULT_OK) {
201 Uri selectedImageUri = data.getData();
202
203 String filemanagerstring = selectedImageUri.getPath();
204 String selectedImagePath = getPath(selectedImageUri);
205 String filepath;
206
207 if (selectedImagePath != null)
208 filepath = selectedImagePath;
209 else
210 filepath = filemanagerstring;
211
212 if (filepath == null) {
213 Log.e("FileDisplay", "Couldnt resolve path to file");
214 return;
215 }
216
217 Intent i = new Intent(this, FileUploader.class);
218 i.putExtra(FileUploader.KEY_ACCOUNT,
219 AccountUtils.getCurrentOwnCloudAccount(this));
220 String remotepath = new String();
221 for (int j = mDirectories.getCount() - 2; j >= 0; --j) {
222 remotepath += "/" + mDirectories.getItem(j);
223 }
224 if (!remotepath.endsWith("/"))
225 remotepath += "/";
226 remotepath += new File(filepath).getName();
227 remotepath = Uri.encode(remotepath, "/");
228
229 i.putExtra(FileUploader.KEY_LOCAL_FILE, filepath);
230 i.putExtra(FileUploader.KEY_REMOTE_FILE, remotepath);
231 i.putExtra(FileUploader.KEY_UPLOAD_TYPE, FileUploader.UPLOAD_SINGLE_FILE);
232 startService(i);
233 }
234
235 }/* dvelasco: WIP - not working as expected ... yet :)
236 else if (requestCode == ACTION_CREATE_FIRST_ACCOUNT) {
237 if (resultCode != RESULT_OK) {
238 finish(); // the user cancelled the AuthenticatorActivity
239 }
240 }*/
241 }
242
243 @Override
244 public void onBackPressed() {
245 if (mDirectories == null || mDirectories.getCount() <= 1) {
246 finish();
247 return;
248 }
249 popDirname();
250 mFileList.onNavigateUp();
251 mCurrentDir = mFileList.getCurrentFile();
252
253 if(mCurrentDir.getParentId() == 0){
254 ActionBar actionBar = getSupportActionBar();
255 actionBar.setDisplayHomeAsUpEnabled(false);
256 }
257 }
258
259 @Override
260 protected void onRestoreInstanceState(Bundle savedInstanceState) {
261 Log.i(getClass().toString(), "onRestoreInstanceState() start");
262 super.onRestoreInstanceState(savedInstanceState);
263 mDirs = savedInstanceState.getStringArray(KEY_DIR_ARRAY);
264 mDirectories = new CustomArrayAdapter<String>(this, R.layout.sherlock_spinner_dropdown_item);
265 mDirectories.add("/");
266 if (mDirs != null)
267 for (String s : mDirs)
268 mDirectories.insert(s, 0);
269 mCurrentDir = savedInstanceState.getParcelable(FileDetailFragment.EXTRA_FILE);
270 Log.i(getClass().toString(), "onRestoreInstanceState() end");
271 }
272
273 @Override
274 protected void onSaveInstanceState(Bundle outState) {
275 Log.i(getClass().toString(), "onSaveInstanceState() start");
276 super.onSaveInstanceState(outState);
277 if(mDirectories != null && mDirectories.getCount() != 0){
278 mDirs = new String[mDirectories.getCount()-1];
279 for (int j = mDirectories.getCount() - 2, i = 0; j >= 0; --j, ++i) {
280 mDirs[i] = mDirectories.getItem(j);
281 }
282 }
283 outState.putStringArray(KEY_DIR_ARRAY, mDirs);
284 outState.putParcelable(FileDetailFragment.EXTRA_FILE, mCurrentDir);
285 Log.i(getClass().toString(), "onSaveInstanceState() end");
286 }
287
288 @Override
289 protected void onResume() {
290 Log.i(getClass().toString(), "onResume() start");
291 super.onResume();
292
293 if (!AccountUtils.accountsAreSetup(this)) {
294 /*Intent intent = new Intent(android.provider.Settings.ACTION_ADD_ACCOUNT);
295 intent.putExtra(android.provider.Settings.EXTRA_AUTHORITIES, new String[] { AccountAuthenticator.AUTH_TOKEN_TYPE });
296 //startActivity(intent);
297 startActivityForResult(intent, ACTION_CREATE_FIRST_ACCOUNT);*/
298
299 } else { // at least an account exist: normal operation
300
301 // set the layout only if it couldn't be set in onCreate
302 if (findViewById(R.id.file_list_view) == null)
303 setContentView(mLayoutView);
304
305 // Listen for sync messages
306 IntentFilter syncIntentFilter = new IntentFilter(FileSyncService.SYNC_MESSAGE);
307 mSyncBroadcastReceiver = new SyncBroadcastReceiver();
308 registerReceiver(mSyncBroadcastReceiver, syncIntentFilter);
309
310 // Listen for upload messages
311 IntentFilter uploadIntentFilter = new IntentFilter(FileUploader.UPLOAD_FINISH_MESSAGE);
312 mUploadFinishReceiver = new UploadFinishReceiver();
313 registerReceiver(mUploadFinishReceiver, uploadIntentFilter);
314
315 // Storage manager initialization
316 mStorageManager = new FileDataStorageManager(
317 AccountUtils.getCurrentOwnCloudAccount(this),
318 getContentResolver());
319
320 // File list
321 mFileList = (FileListFragment) getSupportFragmentManager().findFragmentById(R.id.fileList);
322
323 // Figure out what directory to list.
324 // Priority: Intent (here), savedInstanceState (onCreate), root dir (dir is null)
325 if(getIntent().hasExtra(FileDetailFragment.EXTRA_FILE)){
326 mCurrentDir = (OCFile) getIntent().getParcelableExtra(FileDetailFragment.EXTRA_FILE);
327 if(mCurrentDir != null && !mCurrentDir.isDirectory()){
328 mCurrentDir = mStorageManager.getFileById(mCurrentDir.getParentId());
329 }
330
331 // Clear intent extra, so rotating the screen will not return us to this directory
332 getIntent().removeExtra(FileDetailFragment.EXTRA_FILE);
333 }
334
335 if (mCurrentDir == null)
336 mCurrentDir = mStorageManager.getFileByPath("/");
337
338 // Drop-Down navigation and file list restore
339 mDirectories = new CustomArrayAdapter<String>(this, R.layout.sherlock_spinner_dropdown_item);
340
341
342 // Given the case we have a file to display:
343 if(mCurrentDir != null){
344 ArrayList<OCFile> files = new ArrayList<OCFile>();
345 OCFile currFile = mCurrentDir;
346 while(currFile != null){
347 files.add(currFile);
348 currFile = mStorageManager.getFileById(currFile.getParentId());
349 }
350
351 // Insert in mDirs
352 mDirs = new String[files.size()];
353 for(int i = files.size() - 1; i >= 0; i--){
354 mDirs[i] = files.get(i).getFileName();
355 }
356 }
357
358 if (mDirs != null) {
359 for (String s : mDirs)
360 mDirectories.add(s);
361 } else {
362 mDirectories.add("/");
363 }
364
365 // Actionbar setup
366 ActionBar action_bar = getSupportActionBar();
367 action_bar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
368 action_bar.setDisplayShowTitleEnabled(false);
369 action_bar.setListNavigationCallbacks(mDirectories, this);
370 if(mCurrentDir != null && mCurrentDir.getParentId() != 0){
371 action_bar.setDisplayHomeAsUpEnabled(true);
372 } else {
373 action_bar.setDisplayHomeAsUpEnabled(false);
374 }
375
376 // List dir here
377 mFileList.listDirectory(mCurrentDir);
378 }
379 Log.i(getClass().toString(), "onResume() end");
380 }
381
382 @Override
383 protected void onPause() {
384 Log.i(getClass().toString(), "onPause() start");
385 super.onPause();
386 if (mSyncBroadcastReceiver != null) {
387 unregisterReceiver(mSyncBroadcastReceiver);
388 mSyncBroadcastReceiver = null;
389 }
390 if (mUploadFinishReceiver != null) {
391 unregisterReceiver(mUploadFinishReceiver);
392 mUploadFinishReceiver = null;
393 }
394 getIntent().putExtra(FileDetailFragment.EXTRA_FILE, mCurrentDir);
395 Log.i(getClass().toString(), "onPause() end");
396 }
397
398 @Override
399 protected Dialog onCreateDialog(int id) {
400 Dialog dialog = null;
401 AlertDialog.Builder builder;
402 switch (id) {
403 case DIALOG_SETUP_ACCOUNT:
404 builder = new AlertDialog.Builder(this);
405 builder.setTitle(R.string.main_tit_accsetup);
406 builder.setMessage(R.string.main_wrn_accsetup);
407 builder.setCancelable(false);
408 builder.setPositiveButton(android.R.string.ok, this);
409 builder.setNegativeButton(android.R.string.cancel, this);
410 dialog = builder.create();
411 break;
412 case DIALOG_ABOUT_APP: {
413 builder = new AlertDialog.Builder(this);
414 builder.setTitle("About");
415 PackageInfo pkg;
416 try {
417 pkg = getPackageManager().getPackageInfo(getPackageName(), 0);
418 builder.setMessage("ownCloud android client\n\nversion: " + pkg.versionName );
419 builder.setIcon(android.R.drawable.ic_menu_info_details);
420 dialog = builder.create();
421 } catch (NameNotFoundException e) {
422 builder = null;
423 dialog = null;
424 e.printStackTrace();
425 }
426 break;
427 }
428 case DIALOG_CREATE_DIR: {
429 builder = new Builder(this);
430 final EditText dirNameInput = new EditText(getBaseContext());
431 final Account a = AccountUtils.getCurrentOwnCloudAccount(this);
432 builder.setView(dirNameInput);
433 builder.setTitle(R.string.uploader_info_dirname);
434 int typed_color = getResources().getColor(R.color.setup_text_typed);
435 dirNameInput.setTextColor(typed_color);
436 builder.setPositiveButton(android.R.string.ok,
437 new OnClickListener() {
438 public void onClick(DialogInterface dialog, int which) {
439 String directoryName = dirNameInput.getText().toString();
440 if (directoryName.trim().length() == 0) {
441 dialog.cancel();
442 return;
443 }
444
445 // Figure out the path where the dir needs to be created
446 String path;
447 if (mCurrentDir == null) {
448 // this is just a patch; we should ensure that mCurrentDir never is null
449 if (!mStorageManager.fileExists("/")) {
450 OCFile file = new OCFile("/");
451 mStorageManager.saveFile(file);
452 }
453 mCurrentDir = mStorageManager.getFileByPath("/");
454 }
455 path = FileDisplayActivity.this.mCurrentDir.getRemotePath();
456
457 // Create directory
458 path += Uri.encode(directoryName) + "/";
459 Thread thread = new Thread(new DirectoryCreator(path, a));
460 thread.start();
461
462 // Save new directory in local database
463 OCFile newDir = new OCFile(path);
464 newDir.setMimetype("DIR");
465 newDir.setParentId(mCurrentDir.getFileId());
466 mStorageManager.saveFile(newDir);
467
468 // Display the new folder right away
469 dialog.dismiss();
470 mFileList.listDirectory(mCurrentDir);
471 }
472 });
473 builder.setNegativeButton(R.string.common_cancel,
474 new OnClickListener() {
475 public void onClick(DialogInterface dialog, int which) {
476 dialog.cancel();
477 }
478 });
479 dialog = builder.create();
480 break;
481 }
482 default:
483 dialog = null;
484 }
485
486 return dialog;
487 }
488
489
490 /**
491 * Responds to the "There are no ownCloud Accounts setup" dialog
492 * TODO: Dialog is 100% useless -> Remove
493 */
494 @Override
495 public void onClick(DialogInterface dialog, int which) {
496 // In any case - we won't need it anymore
497 dialog.dismiss();
498 switch (which) {
499 case DialogInterface.BUTTON_POSITIVE:
500 Intent intent = new Intent("android.settings.ADD_ACCOUNT_SETTINGS");
501 intent.putExtra("authorities",
502 new String[] { AccountAuthenticator.AUTH_TOKEN_TYPE });
503 startActivity(intent);
504 break;
505 case DialogInterface.BUTTON_NEGATIVE:
506 finish();
507 }
508
509 }
510
511 /**
512 * Translates a content URI of an image to a physical path
513 * on the disk
514 * @param uri The URI to resolve
515 * @return The path to the image or null if it could not be found
516 */
517 public String getPath(Uri uri) {
518 String[] projection = { MediaStore.Images.Media.DATA };
519 Cursor cursor = managedQuery(uri, projection, null, null, null);
520 if (cursor != null) {
521 int column_index = cursor
522 .getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
523 cursor.moveToFirst();
524 return cursor.getString(column_index);
525 }
526 return null;
527 }
528
529 /**
530 * Pushes a directory to the drop down list
531 * @param directory to push
532 * @throws IllegalArgumentException If the {@link OCFile#isDirectory()} returns false.
533 */
534 public void pushDirname(OCFile directory) {
535 if(!directory.isDirectory()){
536 throw new IllegalArgumentException("Only directories may be pushed!");
537 }
538 mDirectories.insert(directory.getFileName(), 0);
539 mCurrentDir = directory;
540 }
541
542 /**
543 * Pops a directory name from the drop down list
544 * @return True, unless the stack is empty
545 */
546 public boolean popDirname() {
547 mDirectories.remove(mDirectories.getItem(0));
548 return !mDirectories.isEmpty();
549 }
550
551 private class DirectoryCreator implements Runnable {
552 private String mTargetPath;
553 private Account mAccount;
554 private AccountManager mAm;
555
556 public DirectoryCreator(String targetPath, Account account) {
557 mTargetPath = targetPath;
558 mAccount = account;
559 mAm = (AccountManager) getSystemService(ACCOUNT_SERVICE);
560 }
561
562 @Override
563 public void run() {
564 WebdavClient wdc = new WebdavClient(Uri.parse(mAm.getUserData(
565 mAccount, AccountAuthenticator.KEY_OC_URL)));
566
567 String username = mAccount.name.substring(0,
568 mAccount.name.lastIndexOf('@'));
569 String password = mAm.getPassword(mAccount);
570
571 wdc.setCredentials(username, password);
572 wdc.allowSelfsignedCertificates();
573 wdc.createDirectory(mTargetPath);
574 }
575
576 }
577
578 // Custom array adapter to override text colors
579 private class CustomArrayAdapter<T> extends ArrayAdapter<T> {
580
581 public CustomArrayAdapter(FileDisplayActivity ctx, int view) {
582 super(ctx, view);
583 }
584
585 public View getView(int position, View convertView, ViewGroup parent) {
586 View v = super.getView(position, convertView, parent);
587
588 ((TextView) v).setTextColor(getResources().getColorStateList(
589 android.R.color.white));
590 return v;
591 }
592
593 public View getDropDownView(int position, View convertView,
594 ViewGroup parent) {
595 View v = super.getDropDownView(position, convertView, parent);
596
597 ((TextView) v).setTextColor(getResources().getColorStateList(
598 android.R.color.white));
599
600 return v;
601 }
602
603 }
604
605 private class SyncBroadcastReceiver extends BroadcastReceiver {
606 /**
607 * {@link BroadcastReceiver} to enable syncing feedback in UI
608 */
609 @Override
610 public void onReceive(Context context, Intent intent) {
611 boolean inProgress = intent.getBooleanExtra(
612 FileSyncService.IN_PROGRESS, false);
613 String account_name = intent
614 .getStringExtra(FileSyncService.ACCOUNT_NAME);
615 Log.d("FileDisplay", "sync of account " + account_name
616 + " is in_progress: " + inProgress);
617 setSupportProgressBarIndeterminateVisibility(inProgress);
618
619 long OCDirId = intent.getLongExtra(FileSyncService.SYNC_FOLDER, -1);
620 if (OCDirId > 0) {
621 OCFile syncDir = mStorageManager.getFileById(OCDirId);
622 if (syncDir != null && (
623 (mCurrentDir == null && syncDir.getFileName().equals("/")) ||
624 syncDir.equals(mCurrentDir))
625 ) {
626 FileListFragment fileListFragment = (FileListFragment) getSupportFragmentManager().findFragmentById(R.id.fileList);
627 if (fileListFragment != null) {
628 fileListFragment.listDirectory();
629 }
630 }
631 }
632
633 if (!inProgress) {
634 FileListFragment fileListFragment = (FileListFragment) getSupportFragmentManager()
635 .findFragmentById(R.id.fileList);
636 if (fileListFragment != null)
637 fileListFragment.listDirectory();
638 }
639 }
640
641 }
642
643
644 private class UploadFinishReceiver extends BroadcastReceiver {
645 /**
646 * Once the file upload has finished -> update view
647 * @author David A. Velasco
648 * {@link BroadcastReceiver} to enable upload feedback in UI
649 */
650 @Override
651 public void onReceive(Context context, Intent intent) {
652 long parentDirId = intent.getLongExtra(FileUploader.EXTRA_PARENT_DIR_ID, -1);
653 OCFile parentDir = mStorageManager.getFileById(parentDirId);
654
655 if (parentDir != null && (
656 (mCurrentDir == null && parentDir.getFileName().equals("/")) ||
657 parentDir.equals(mCurrentDir))
658 ) {
659 FileListFragment fileListFragment = (FileListFragment) getSupportFragmentManager().findFragmentById(R.id.fileList);
660 if (fileListFragment != null) {
661 fileListFragment.listDirectory();
662 }
663 }
664 }
665
666 }
667
668
669 @Override
670 public void onClick(View v) {
671 if (v.getId() == R.id.setup_account) {
672 Intent intent = new Intent("android.settings.ADD_ACCOUNT_SETTINGS");
673 intent.putExtra("authorities", new String[] { AccountAuthenticator.AUTH_TOKEN_TYPE });
674 startActivity(intent);
675 }
676 }
677
678 public DataStorageManager getStorageManager() {
679 return mStorageManager;
680 }
681 }