private OperationsServiceBinder mOperationsServiceBinder = null;
+ private boolean mResumed = false;
+
protected FileDownloaderBinder mDownloaderBinder = null;
protected FileUploaderBinder mUploaderBinder = null;
private ServiceConnection mDownloadServiceConnection, mUploadServiceConnection = null;
@Override
protected void onResume() {
super.onResume();
-
+ mResumed = true;
if (mOperationsServiceBinder != null) {
doOnResumeAndBound();
}
if (mOperationsServiceBinder != null) {
mOperationsServiceBinder.removeOperationListener(this);
}
-
+ mResumed = false;
super.onPause();
}
// }
// Display username in drawer
- Account account = AccountUtils.getCurrentOwnCloudAccount(getApplicationContext());
- if (account != null) {
- TextView username = (TextView) navigationDrawerLayout.findViewById(R.id.drawer_username);
- int lastAtPos = account.name.lastIndexOf("@");
- username.setText(account.name.substring(0, lastAtPos));
- }
+ setUsernameInDrawer(navigationDrawerLayout, AccountUtils.getCurrentOwnCloudAccount(getApplicationContext()));
// load slide menu items
mDrawerTitles = getResources().getStringArray(R.array.drawer_items);
mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[0], mDrawerContentDescriptions[0],
R.drawable.ic_folder_open));
- // TODO Enable when "On Device" is recovered
// On Device
- //mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[2],
- // mDrawerContentDescriptions[2]));
+ mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[1], mDrawerContentDescriptions[1],
+ R.drawable.ic_action_download_grey));
// Settings
- mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[1], mDrawerContentDescriptions[1],
- R.drawable.ic_settings));
+ mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[2], mDrawerContentDescriptions[2],
+ R.drawable.ic_action_settings));
// Logs
if (BuildConfig.DEBUG) {
- mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[2],
- mDrawerContentDescriptions[2],R.drawable.ic_log));
+ mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[3],
+ mDrawerContentDescriptions[3],R.drawable.ic_log));
}
// setting the nav drawer list adapter
}
/**
+ * sets the given account name in the drawer in case the drawer is available. The account name
+ * is shortened beginning from the @-sign in the username.
+ *
+ * @param navigationDrawerLayout the drawer layout to be used
+ * @param account the account to be set in the drawer
+ */
+ protected void setUsernameInDrawer(RelativeLayout navigationDrawerLayout, Account account) {
+ if (navigationDrawerLayout != null && getAccount() != null) {
+ TextView username = (TextView) navigationDrawerLayout.findViewById(R.id.drawer_username);
+ int lastAtPos = account.name.lastIndexOf("@");
+ username.setText(account.name.substring(0, lastAtPos));
+ }
+ }
+
+ /**
* Updates title bar and home buttons (state and icon).
*
* Assumes that navigation drawer is NOT visible.
onSynchronizeFileOperationFinish((SynchronizeFileOperation) operation, result);
} else if (operation instanceof GetSharesForFileOperation) {
- if (result.isSuccess()) {
+ if (result.isSuccess() || result.getCode() == ResultCode.SHARE_NOT_FOUND) {
updateFileFromDB();
- } else if (result.getCode() != ResultCode.SHARE_NOT_FOUND) {
+ } else {
Toast t = Toast.makeText(this,
ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()),
Toast.LENGTH_LONG);
if (result.getCode() == ResultCode.SHARE_FORBIDDEN) {
String password = operation.getPassword();
if ((password == null || password.length() == 0) &&
- !getCapabilities().getFilesSharingPublicEnabled().isFalse())
+ getCapabilities().getFilesSharingPublicEnabled().isUnknown())
{
// Was tried without password, but not sure that it's optional. Try with password.
// Try with password before giving up.
public void dismissLoadingDialog() {
Fragment frag = getSupportFragmentManager().findFragmentByTag(DIALOG_WAIT_TAG);
if (frag != null) {
+ Log_OC.d(TAG, "dismiss loading dialog");
LoadingDialog loading = (LoadingDialog) frag;
loading.dismiss();
}
/*if (!mOperationsServiceBinder.isPerformingBlockingOperation()) {
dismissLoadingDialog();
}*/
- doOnResumeAndBound();
+ if (mResumed) {
+ doOnResumeAndBound();
+ }
} else {
return;
startActivity(i);
}
+ public void refresh(){
+ Intent i = new Intent(this, FileDisplayActivity.class);
+ i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ startActivity(i);
+ }
+
// TODO re-enable when "Accounts" is available in Navigation Drawer
// public void closeDrawer() {
// mDrawerLayout.closeDrawers();
restart();
}
+ public void refreshDirectory(){
+ // overridden by FileDisplayActivity
+ }
+
private class DrawerItemClickListener implements ListView.OnItemClickListener {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// break;
case 0: // All Files
- allFilesOption();
+ MainApp.showOnlyFilesOnDevice(false);
+ refreshDirectory();
mDrawerLayout.closeDrawers();
break;
- // TODO Enable when "On Device" is recovered ?
-// case 2:
-// MainApp.showOnlyFilesOnDevice(true);
-// mDrawerLayout.closeDrawers();
-// break;
+ case 1: // On Device
+ MainApp.showOnlyFilesOnDevice(true);
+ refreshDirectory();
+ mDrawerLayout.closeDrawers();
+ break;
- case 1: // Settings
+ case 2: // Settings
Intent settingsIntent = new Intent(getApplicationContext(),
Preferences.class);
startActivity(settingsIntent);
mDrawerLayout.closeDrawers();
break;
- case 2: // Logs
+ case 3: // Logs
Intent loggerIntent = new Intent(getApplicationContext(),
LogHistoryActivity.class);
startActivity(loggerIntent);