X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/f89e112f14b6a22b5d02f52a900f10fd02769d4a..1ef9c86b59575ece900b9770c39184e5e2011918:/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 9ce66d5e..b1c0ffbe 100644 --- a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -54,10 +54,7 @@ import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; -import android.view.ViewGroup; import android.view.Window; -import android.widget.ArrayAdapter; -import android.widget.TextView; import android.widget.Toast; import com.owncloud.android.MainApp; @@ -77,7 +74,6 @@ import com.owncloud.android.lib.common.operations.RemoteOperation; import com.owncloud.android.lib.common.operations.RemoteOperationResult; import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode; import com.owncloud.android.lib.common.utils.Log_OC; -import com.owncloud.android.lib.resources.files.FileUtils; import com.owncloud.android.operations.CreateFolderOperation; import com.owncloud.android.operations.CreateShareOperation; import com.owncloud.android.operations.MoveFileOperation; @@ -264,7 +260,7 @@ public class FileDisplayActivity extends HookActivity } else { updateFragmentsVisibility(!file.isFolder()); - updateNavigationElementsInActionBar(file.isFolder() ? null : file); + updateActionBarTitleAndHomeButton(file.isFolder() ? null : file); } } } @@ -295,7 +291,7 @@ public class FileDisplayActivity extends HookActivity if (secondFragment != null) { setSecondFragment(secondFragment); updateFragmentsVisibility(true); - updateNavigationElementsInActionBar(file); + updateActionBarTitleAndHomeButton(file); } else { cleanSecondFragment(); @@ -403,7 +399,7 @@ public class FileDisplayActivity extends HookActivity tr.commit(); } updateFragmentsVisibility(false); - updateNavigationElementsInActionBar(null); + updateActionBarTitleAndHomeButton(null); } protected void refreshListOfFilesFragment() { @@ -500,16 +496,14 @@ public class FileDisplayActivity extends HookActivity case android.R.id.home: { FileFragment second = getSecondFragment(); OCFile currentDir = getCurrentDir(); - if((currentDir != null && currentDir.getParentId() != 0) || + if (mDrawerLayout.isDrawerOpen(GravityCompat.START)) { + mDrawerLayout.closeDrawer(GravityCompat.START); + } else if((currentDir != null && currentDir.getParentId() != 0) || (second != null && second.getFile() != null)) { onBackPressed(); } else { - if (mDrawerLayout.isDrawerOpen(GravityCompat.START)) { - mDrawerLayout.closeDrawer(GravityCompat.START); - } else { - mDrawerLayout.openDrawer(GravityCompat.START); - } + mDrawerLayout.openDrawer(GravityCompat.START); } break; } @@ -739,6 +733,10 @@ public class FileDisplayActivity extends HookActivity public void onBackPressed() { OCFileListFragment listOfFiles = getListOfFilesFragment(); if (mDualPane || getSecondFragment() == null) { + if (getFile() != null && getFile().getParentId() == 0) { + finish(); + return; + } if (listOfFiles != null) { // should never be null, indeed listOfFiles.onBrowseUp(); } @@ -746,7 +744,6 @@ public class FileDisplayActivity extends HookActivity if (listOfFiles != null) { // should never be null, indeed setFile(listOfFiles.getCurrentFile()); } - updateActionBarTitle(); cleanSecondFragment(); } @@ -776,6 +773,7 @@ public class FileDisplayActivity extends HookActivity // refresh Navigation Drawer account list mNavigationDrawerAdapter.updateAccountList(); + // refresh list of files refreshListOfFilesFragment(); @@ -1124,7 +1122,6 @@ public class FileDisplayActivity extends HookActivity // listOfFiles.listDirectory(root, MainApp.getOnlyOnDevice()); setFile(listOfFiles.getCurrentFile()); startSyncFolderOperation(root, false); - updateActionBarTitle(); } cleanSecondFragment(); @@ -1138,11 +1135,10 @@ public class FileDisplayActivity extends HookActivity */ @Override public void onBrowsedDownTo(OCFile directory) { + setFile(directory); cleanSecondFragment(); - updateActionBarTitle(); // Sync Folder startSyncFolderOperation(directory, false); - } /** @@ -1156,49 +1152,20 @@ public class FileDisplayActivity extends HookActivity Fragment detailFragment = new FileDetailFragment(file, getAccount()); setSecondFragment(detailFragment); updateFragmentsVisibility(true); - updateNavigationElementsInActionBar(file); + updateActionBarTitleAndHomeButton(file); setFile(file); } - - /** - * TODO - */ - private void updateNavigationElementsInActionBar(OCFile chosenFile) { - ActionBar actionBar = getSupportActionBar(); - - // For adding content description tag to a title field in the action bar - int actionBarTitleId = getResources().getIdentifier("action_bar_title", "id", "android"); - - if (chosenFile == null || mDualPane) { - // only list of files - set for browsing through folders - OCFile currentDir = getCurrentDir(); - boolean noRoot = (currentDir != null && currentDir.getParentId() != 0); -// actionBar.setDisplayHomeAsUpEnabled(noRoot); -// actionBar.setDisplayShowTitleEnabled(!noRoot); - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowTitleEnabled(true); - if (!noRoot) { - actionBar.setTitle(getString(R.string.default_display_name_for_root_folder)); - View actionBarTitleView = getWindow().getDecorView().findViewById(actionBarTitleId); - if (actionBarTitleView != null) { // it's null in Android 2.x - actionBarTitleView.setContentDescription( - getString(R.string.default_display_name_for_root_folder)); - } - } - actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); + @Override + protected void updateActionBarTitleAndHomeButton(OCFile chosenFile) { + if (mDualPane) { + // in dual pane mode, keep the focus of title an action bar in the current folder + super.updateActionBarTitleAndHomeButton(getCurrentDir()); } else { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowTitleEnabled(true); - actionBar.setTitle(chosenFile.getFileName()); - actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); - View actionBarTitleView = getWindow().getDecorView().findViewById(actionBarTitleId); - if (actionBarTitleView != null) { // it's null in Android 2.x - getWindow().getDecorView().findViewById(actionBarTitleId). - setContentDescription(chosenFile.getFileName()); - } + super.updateActionBarTitleAndHomeButton(chosenFile); } + } @@ -1662,7 +1629,7 @@ public class FileDisplayActivity extends HookActivity autoplay); setSecondFragment(mediaFragment); updateFragmentsVisibility(true); - updateNavigationElementsInActionBar(file); + updateActionBarTitleAndHomeButton(file); setFile(file); } @@ -1679,7 +1646,7 @@ public class FileDisplayActivity extends HookActivity mWaitingToPreview = file; requestForDownload(); updateFragmentsVisibility(true); - updateNavigationElementsInActionBar(file); + updateActionBarTitleAndHomeButton(file); setFile(file); }