import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
+import android.support.v4.content.ContextCompat;
import android.support.v4.view.GravityCompat;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
-import android.view.Window;
+import android.widget.ProgressBar;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
import android.widget.Toast;
import com.owncloud.android.MainApp;
private boolean mDualPane;
private View mLeftFragmentContainer;
private View mRightFragmentContainer;
+ private ProgressBar mProgressBar;
private static final String KEY_WAITING_TO_PREVIEW = "WAITING_TO_PREVIEW";
private static final String KEY_SYNC_IN_PROGRESS = "SYNC_IN_PROGRESS";
@Override
protected void onCreate(Bundle savedInstanceState) {
Log_OC.v(TAG, "onCreate() start");
- requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
super.onCreate(savedInstanceState); // this calls onAccountChanged() when ownCloud Account
// is valid
// Navigation Drawer
initDrawer();
+ mProgressBar = (ProgressBar) findViewById(R.id.progressBar);
+ mProgressBar.setIndeterminateDrawable(
+ ContextCompat.getDrawable(this,
+ R.drawable.actionbar_progress_indeterminate_horizontal));
+
mDualPane = getResources().getBoolean(R.bool.large_land_layout);
mLeftFragmentContainer = findViewById(R.id.left_fragment_container);
mRightFragmentContainer = findViewById(R.id.right_fragment_container);
// according to the official
// documentation
- setSupportProgressBarIndeterminateVisibility(mSyncInProgress
- /*|| mRefreshSharesInProgress*/);
+ // enable ActionBar app icon to behave as action to toggle nav drawer
+ //getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+ getSupportActionBar().setHomeButtonEnabled(true);
+
+ mProgressBar.setIndeterminate(mSyncInProgress);
// always AFTER setContentView(...) ; to work around bug in its implementation
setBackgroundText();
protected void onStart() {
Log_OC.v(TAG, "onStart() start");
super.onStart();
- getSupportActionBar().setIcon(DisplayUtils.getSeasonalIconId());
Log_OC.v(TAG, "onStart() end");
}
file = getStorageManager().getFileByPath(OCFile.ROOT_PATH); // never returns null
}
setFile(file);
-
+
+ if (mAccountWasSet) {
+ RelativeLayout navigationDrawerLayout = (RelativeLayout) findViewById(R.id.left_drawer);
+ if (navigationDrawerLayout != null && getAccount() != null) {
+ TextView username = (TextView) navigationDrawerLayout.findViewById(R.id.drawer_username);
+ int lastAtPos = getAccount().name.lastIndexOf("@");
+ username.setText(getAccount().name.substring(0, lastAtPos));
+ }
+ }
+
if (!stateWasRecovered) {
Log_OC.d(TAG, "Initializing Fragments in onAccountChanged..");
initFragmentsWithFile();
@Override
public void onBackPressed() {
- OCFileListFragment listOfFiles = getListOfFilesFragment();
- if (mDualPane || getSecondFragment() == null) {
- OCFile currentDir = getCurrentDir();
- if (currentDir == null || currentDir.getParentId() == FileDataStorageManager.ROOT_PARENT_ID) {
- finish();
- return;
+ if (!isDrawerOpen()){
+ OCFileListFragment listOfFiles = getListOfFilesFragment();
+ if (mDualPane || getSecondFragment() == null) {
+ OCFile currentDir = getCurrentDir();
+ if (currentDir == null || currentDir.getParentId() == FileDataStorageManager.ROOT_PARENT_ID) {
+ finish();
+ return;
+ }
+ if (listOfFiles != null) { // should never be null, indeed
+ listOfFiles.onBrowseUp();
+ }
}
if (listOfFiles != null) { // should never be null, indeed
- listOfFiles.onBrowseUp();
+ setFile(listOfFiles.getCurrentFile());
}
+ cleanSecondFragment();
+ } else {
+ super.onBackPressed();
}
- if (listOfFiles != null) { // should never be null, indeed
- setFile(listOfFiles.getCurrentFile());
- }
- cleanSecondFragment();
-
}
@Override
}
removeStickyBroadcast(intent);
Log_OC.d(TAG, "Setting progress visibility to " + mSyncInProgress);
- setSupportProgressBarIndeterminateVisibility(mSyncInProgress
- /*|| mRefreshSharesInProgress*/);
+ mProgressBar.setIndeterminate(mSyncInProgress);
+ //mProgressBar.setVisibility((mSyncInProgress) ? View.VISIBLE : View.INVISIBLE);
+ //setSupportProgressBarIndeterminateVisibility(mSyncInProgress
+ /*|| mRefreshSharesInProgress*/ //);
setBackgroundText();
startImagePreview(getFile());
} // TODO what about other kind of previews?
}
-
+
+ mProgressBar.setIndeterminate(false);
} finally {
if (intent != null) {
removeStickyBroadcast(intent);
}
-
@Override
protected ServiceConnection newTransferenceServiceConnection() {
return new ListServiceConnection();
getApplicationContext()
);
synchFolderOp.execute(getAccount(), MainApp.getAppContext(), this, null, null);
-
- setSupportProgressBarIndeterminateVisibility(true);
+ mProgressBar.setIndeterminate(true);
setBackgroundText();
}