X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/533924f538857508a0f09ac986ad45f9a7acec71..59fdac1d26c480f83072f02849c89caadf55ba6c:/src/com/owncloud/android/ui/activity/FileDisplayActivity.java diff --git a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java index 9d10a556..d5c0d5a9 100644 --- a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -43,7 +43,7 @@ import android.preference.PreferenceManager; import android.provider.MediaStore; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentTransaction; -import android.support.v4.content.LocalBroadcastManager; +//import android.support.v4.content.LocalBroadcastManager; import android.util.Log; import android.view.View; import android.view.ViewGroup; @@ -98,7 +98,7 @@ import com.owncloud.android.utils.Log_OC; * @author David A. Velasco */ -public class FileDisplayActivity extends FileActivity implements +public class FileDisplayActivity extends HookActivity implements OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNavigationListener, OnSslValidatorListener, EditNameDialogListener { private ArrayAdapter mDirectories; @@ -531,7 +531,8 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa // the next operation triggers a new call to this method, but it's necessary to // ensure that the name exposed in the action bar is the current directory when the // user selected it in the navigation list - getSupportActionBar().setSelectedNavigationItem(0); + if (getSupportActionBar().getNavigationMode() == ActionBar.NAVIGATION_MODE_LIST && itemPosition != 0) + getSupportActionBar().setSelectedNavigationItem(0); } return true; } @@ -677,8 +678,8 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa syncIntentFilter.addAction(SynchronizeFolderOperation.EVENT_SINGLE_FOLDER_CONTENTS_SYNCED); syncIntentFilter.addAction(SynchronizeFolderOperation.EVENT_SINGLE_FOLDER_SHARES_SYNCED); mSyncBroadcastReceiver = new SyncBroadcastReceiver(); - //registerReceiver(mSyncBroadcastReceiver, syncIntentFilter); - LocalBroadcastManager.getInstance(this).registerReceiver(mSyncBroadcastReceiver, syncIntentFilter); + registerReceiver(mSyncBroadcastReceiver, syncIntentFilter); + //LocalBroadcastManager.getInstance(this).registerReceiver(mSyncBroadcastReceiver, syncIntentFilter); // Listen for upload messages IntentFilter uploadIntentFilter = new IntentFilter(FileUploader.getUploadFinishMessage()); @@ -708,8 +709,8 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa super.onPause(); Log_OC.e(TAG, "onPause() start"); if (mSyncBroadcastReceiver != null) { - //unregisterReceiver(mSyncBroadcastReceiver); - LocalBroadcastManager.getInstance(this).unregisterReceiver(mSyncBroadcastReceiver); + unregisterReceiver(mSyncBroadcastReceiver); + //LocalBroadcastManager.getInstance(this).unregisterReceiver(mSyncBroadcastReceiver); mSyncBroadcastReceiver = null; } if (mUploadFinishReceiver != null) { @@ -873,6 +874,8 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa ((TextView) v).setTextColor(getResources().getColorStateList( android.R.color.white)); + + fixRoot((TextView) v ); return v; } @@ -883,9 +886,16 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa ((TextView) v).setTextColor(getResources().getColorStateList( android.R.color.white)); + fixRoot((TextView) v ); return v; } + private void fixRoot(TextView v) { + if (v.getText().equals(OCFile.PATH_SEPARATOR)) { + v.setText(R.string.default_display_name_for_root_folder); + } + } + } private class SyncBroadcastReceiver extends BroadcastReceiver { @@ -896,6 +906,7 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa @Override public void onReceive(Context context, Intent intent) { String event = intent.getAction(); + Log_OC.d(TAG, "Received broadcast " + event); String accountName = intent.getStringExtra(FileSyncAdapter.EXTRA_ACCOUNT_NAME); String synchFolderRemotePath = intent.getStringExtra(FileSyncAdapter.EXTRA_FOLDER_PATH); RemoteOperationResult synchResult = (RemoteOperationResult)intent.getSerializableExtra(FileSyncAdapter.EXTRA_RESULT); @@ -903,7 +914,10 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa if (sameAccount) { - if (!FileSyncAdapter.EVENT_FULL_SYNC_START.equals(event)) { + if (FileSyncAdapter.EVENT_FULL_SYNC_START.equals(event)) { + mSyncInProgress = true; + + } else { OCFile currentFile = (getFile() == null) ? null : getStorageManager().getFileByPath(getFile().getRemotePath()); OCFile currentDir = (getCurrentDir() == null) ? null : getStorageManager().getFileByPath(getCurrentDir().getRemotePath()); @@ -947,7 +961,8 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa */ } - //removeStickyBroadcast(intent); + removeStickyBroadcast(intent); + Log_OC.d(TAG, "Setting progress visibility to " + mSyncInProgress); setSupportProgressBarIndeterminateVisibility(mSyncInProgress /*|| mRefreshSharesInProgress*/); } @@ -1172,9 +1187,13 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa if (chosenFile == null || mDualPane) { // only list of files - set for browsing through folders OCFile currentDir = getCurrentDir(); - actionBar.setDisplayHomeAsUpEnabled(currentDir != null && currentDir.getParentId() != 0); - actionBar.setDisplayShowTitleEnabled(false); - actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); + boolean noRoot = (currentDir != null && currentDir.getParentId() != 0); + actionBar.setDisplayHomeAsUpEnabled(noRoot); + actionBar.setDisplayShowTitleEnabled(!noRoot); + if (!noRoot) { + actionBar.setTitle(getString(R.string.default_display_name_for_root_folder)); + } + actionBar.setNavigationMode(!noRoot ? ActionBar.NAVIGATION_MODE_STANDARD : ActionBar.NAVIGATION_MODE_LIST); actionBar.setListNavigationCallbacks(mDirectories, this); // assuming mDirectories is updated } else { @@ -1522,6 +1541,7 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa RemoteOperation synchFolderOp = new SynchronizeFolderOperation( folder, currentSyncTime, false, + getFileOperationsHelper().isSharedSupported(this), getStorageManager(), getAccount(), getApplicationContext()