From: David A. Velasco Date: Tue, 9 Jul 2013 11:25:43 +0000 (+0200) Subject: Merge remote-tracking branch 'origin/bug_folder_size_delay' into bug_folder_size_delay X-Git-Tag: oc-android-1.4.3~7^2 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/fffa77e2115c03dfad403b0f9106736256b7c10b?hp=-c Merge remote-tracking branch 'origin/bug_folder_size_delay' into bug_folder_size_delay --- fffa77e2115c03dfad403b0f9106736256b7c10b diff --combined src/com/owncloud/android/ui/activity/FileDisplayActivity.java index e5383ed4,125fd9e3..0ce6ccee --- a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java @@@ -137,10 -137,10 +137,10 @@@ OCFileListFragment.ContainerActivity, F @Override protected void onCreate(Bundle savedInstanceState) { Log_OC.d(TAG, "onCreate() start"); - super.onCreate(savedInstanceState); - requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); - + + super.onCreate(savedInstanceState); // this calls onAccountChanged() when ownCloud Account is valid + mHandler = new Handler(); /// bindings to transference services @@@ -176,13 -176,27 +176,13 @@@ mRightFragmentContainer = findViewById(R.id.right_fragment_container); if (savedInstanceState == null) { createMinFragments(); - if (!isRedirectingToSetupAccount()) { - initFragmentsWithFile(); - } } // Action bar setup mDirectories = new CustomArrayAdapter(this, R.layout.sherlock_spinner_dropdown_item); - OCFile currFile = getFile(); - if (mStorageManager != null) { - while(currFile != null && currFile.getFileName() != OCFile.PATH_SEPARATOR) { - if (currFile.isDirectory()) { - mDirectories.add(currFile.getFileName()); - } - currFile = mStorageManager.getFileById(currFile.getParentId()); - } - } - mDirectories.add(OCFile.PATH_SEPARATOR); - ActionBar actionBar = getSupportActionBar(); - actionBar.setHomeButtonEnabled(true); // mandatory since Android ICS, according to the official documentation - setSupportProgressBarIndeterminateVisibility(false); // always AFTER setContentView(...) ; to workaround bug in its implementation - + getSupportActionBar().setHomeButtonEnabled(true); // mandatory since Android ICS, according to the official documentation + setSupportProgressBarIndeterminateVisibility(false); // always AFTER setContentView(...) ; to work around bug in its implementation + Log_OC.d(TAG, "onCreate() end"); } @@@ -219,28 -233,17 +219,28 @@@ } if (file == null) { // fall back to root folder - file = mStorageManager.getFileByPath(OCFile.PATH_SEPARATOR); // never should return null + file = mStorageManager.getFileByPath(OCFile.PATH_SEPARATOR); // never returns null } setFile(file); - - if (findViewById(android.R.id.content) != null && !stateWasRecovered) { + mDirectories.clear(); + OCFile fileIt = file; + while(fileIt != null && fileIt.getFileName() != OCFile.PATH_SEPARATOR) { + if (fileIt.isDirectory()) { + mDirectories.add(fileIt.getFileName()); + } + fileIt = mStorageManager.getFileById(fileIt.getParentId()); + } + mDirectories.add(OCFile.PATH_SEPARATOR); + if (!stateWasRecovered) { Log_OC.e(TAG, "Initializing Fragments in onAccountChanged.."); initFragmentsWithFile(); + } else { - Log_OC.e(TAG, "Fragment initializacion ignored in onAccountChanged due to lack of CONTENT VIEW"); + updateFragmentsVisibility(!file.isDirectory()); + updateNavigationElementsInActionBar(file.isDirectory() ? null : file); } - + + } else { Log_OC.wtf(TAG, "onAccountChanged was called with NULL account associated!"); } @@@ -256,24 -259,11 +256,24 @@@ private void initFragmentsWithFile() { if (getAccount() != null && getFile() != null) { + /// First fragment + OCFileListFragment listOfFiles = getListOfFilesFragment(); + if (listOfFiles != null) { + listOfFiles.listDirectory(getCurrentDir()); + } else { + Log.e(TAG, "Still have a chance to lose the initializacion of list fragment >("); + } + /// Second fragment OCFile file = getFile(); Fragment secondFragment = chooseInitialSecondFragment(file); if (secondFragment != null) { setSecondFragment(secondFragment); + updateFragmentsVisibility(true); + updateNavigationElementsInActionBar(file); + + } else { + cleanSecondFragment(); } } else { @@@ -371,9 -361,8 +371,9 @@@ FragmentTransaction tr = getSupportFragmentManager().beginTransaction(); tr.remove(second); tr.commit(); - updateFragmentsVisibility(false); } + updateFragmentsVisibility(false); + updateNavigationElementsInActionBar(null); } protected void refeshListOfFilesFragment() { @@@ -598,6 -587,7 +598,6 @@@ setFile(listOfFiles.getCurrentFile()); } cleanSecondFragment(); - updateNavigationElementsInActionBar(null); } @Override @@@ -610,6 -600,14 +610,6 @@@ } @Override - protected void onStart() { - super.onStart(); - FileFragment second = getSecondFragment(); - updateFragmentsVisibility(second != null); - updateNavigationElementsInActionBar((second == null) ? null : second.getFile()); - } - - @Override protected void onResume() { super.onResume(); Log_OC.e(TAG, "onResume() start"); @@@ -629,7 -627,13 +629,7 @@@ downloadIntentFilter.addAction(FileDownloader.DOWNLOAD_FINISH_MESSAGE); mDownloadFinishReceiver = new DownloadFinishReceiver(); registerReceiver(mDownloadFinishReceiver, downloadIntentFilter); - - // List current directory - OCFileListFragment listOfFiles = getListOfFilesFragment(); - if (listOfFiles != null) { - listOfFiles.listDirectory(getCurrentDir()); // TODO we should find the way to avoid the need of this (maybe it's not necessary yet; to check) - } - + Log_OC.d(TAG, "onResume() end"); } @@@ -840,14 -844,19 +840,14 @@@ || fillBlankRoot ) { if (!fillBlankRoot) currentDir = getStorageManager().getFileByPath(synchFolderRemotePath); -// OCFileListFragment fileListFragment = getListOfFilesFragment(); -// if (fileListFragment != null) { -// fileListFragment.listDirectory(currentDir); -// } - } - - OCFileListFragment fileListFragment = getListOfFilesFragment(); - if (fileListFragment != null) { - fileListFragment.listDirectory(currentDir); + OCFileListFragment fileListFragment = getListOfFilesFragment(); + if (fileListFragment != null) { + fileListFragment.listDirectory(currentDir); + } + if (getSecondFragment() == null) + setFile(currentDir); } - - setFile(currentDir); - + setSupportProgressBarIndeterminateVisibility(inProgress); removeStickyBroadcast(intent); @@@ -936,6 -945,7 +936,6 @@@ public void onBrowsedDownTo(OCFile directory) { pushDirname(directory); cleanSecondFragment(); - updateNavigationElementsInActionBar(null); } /** @@@ -1005,9 -1015,9 +1005,9 @@@ /** * TODO */ - private void updateNavigationElementsInActionBar(OCFile currentFile) { + private void updateNavigationElementsInActionBar(OCFile chosenFile) { ActionBar actionBar = getSupportActionBar(); - if (currentFile == null || mDualPane) { + if (chosenFile == null || mDualPane) { // only list of files - set for browsing through folders OCFile currentDir = getCurrentDir(); actionBar.setDisplayHomeAsUpEnabled(currentDir != null && currentDir.getParentId() != 0); @@@ -1018,7 -1028,7 +1018,7 @@@ } else { actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowTitleEnabled(true); - actionBar.setTitle(currentFile.getFileName()); + actionBar.setTitle(chosenFile.getFileName()); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); } } @@@ -1028,6 -1038,15 +1028,6 @@@ * {@inheritDoc} */ @Override - public OCFile getInitialDirectory() { - return getCurrentDir(); - } - - - /** - * {@inheritDoc} - */ - @Override public void onFileStateChanged() { refeshListOfFilesFragment(); updateNavigationElementsInActionBar(getSecondFragment().getFile()); @@@ -1326,11 -1345,12 +1326,11 @@@ if (file != null) { if (file.isDirectory()) { return file; - } else { + } else if (mStorageManager != null) { return mStorageManager.getFileById(file.getParentId()); } - } else { - return null; } + return null; } } diff --combined src/com/owncloud/android/ui/fragment/OCFileListFragment.java index b9d386f1,06349650..c6744422 --- a/src/com/owncloud/android/ui/fragment/OCFileListFragment.java +++ b/src/com/owncloud/android/ui/fragment/OCFileListFragment.java @@@ -63,9 -63,6 +63,9 @@@ import android.widget.AdapterView.Adapt public class OCFileListFragment extends ExtendedListFragment implements EditNameDialogListener, ConfirmationDialogFragmentListener { private static final String TAG = OCFileListFragment.class.getSimpleName(); + + private static final String MY_PACKAGE = OCFileListFragment.class.getPackage() != null ? OCFileListFragment.class.getPackage().getName() : "com.owncloud.android.ui.fragment"; + private static final String EXTRA_FILE = MY_PACKAGE + ".extra.FILE"; private OCFileListFragment.ContainerActivity mContainerActivity; @@@ -97,10 -94,7 +97,10 @@@ public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); Log_OC.e(TAG, "onActivityCreated() start"); - mAdapter = new FileListListAdapter(mContainerActivity.getInitialDirectory(), mContainerActivity.getStorageManager(), getActivity(), mContainerActivity); + mAdapter = new FileListListAdapter(getActivity(), mContainerActivity); + if (savedInstanceState != null) { + mFile = savedInstanceState.getParcelable(EXTRA_FILE); + } setListAdapter(mAdapter); registerForContextMenu(getListView()); @@@ -109,16 -103,7 +109,16 @@@ mHandler = new Handler(); } + + /** + * Saves the current listed folder. + */ + @Override + public void onSaveInstanceState (Bundle outState) { + super.onSaveInstanceState(outState); + outState.putParcelable(EXTRA_FILE, mFile); + } - + /** * Call this, when the user presses the up button @@@ -140,6 -125,7 +140,6 @@@ if (file != null) { if (file.isDirectory()) { // update state and view of this fragment - mFile = file; listDirectory(file); // then, notify parent activity to let it update its state and view, and other fragments mContainerActivity.onBrowsedDownTo(file); @@@ -404,6 -390,14 +404,6 @@@ /** - * Callback method invoked when the parent activity is fully created to get the directory to list firstly. - * - * @return Directory to list firstly. Can be NULL. - */ - public OCFile getInitialDirectory(); - - - /** * Callback method invoked when a the 'transfer state' of a file changes. * * This happens when a download or upload is started or ended for a file.