import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
+import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.RelativeLayout;
+import android.widget.TextView;
import android.widget.Toast;
import com.owncloud.android.BuildConfig;
super.onBackPressed();
}
+ /**
+ * checks if the drawer exists and is opened.
+ *
+ * @return <code>true</code> if the drawer is open, else <code>false</code>
+ */
public boolean isDrawerOpen() {
- return mDrawerLayout.isDrawerOpen(GravityCompat.START);
+ if(mDrawerLayout != null) {
+ return mDrawerLayout.isDrawerOpen(GravityCompat.START);
+ } else {
+ return false;
+ }
}
+ /**
+ * closes the navigation drawer.
+ */
public void closeNavDrawer() {
- mDrawerLayout.closeDrawer(GravityCompat.START);
+ if(mDrawerLayout != null) {
+ mDrawerLayout.closeDrawer(GravityCompat.START);
+ }
}
protected void initDrawer(){
// username.setText(account.name.substring(0, lastAtPos));
// }
+ // 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));
+ }
+
// load slide menu items
mDrawerTitles = getResources().getStringArray(R.array.drawer_items);
// Set the drawer toggle as the DrawerListener
mDrawerLayout.setDrawerListener(mDrawerToggle);
-
+ mDrawerToggle.setDrawerIndicatorEnabled(false);
}
/**
i.putExtra(ConflictsResolveActivity.EXTRA_FILE, syncedFile);
i.putExtra(ConflictsResolveActivity.EXTRA_ACCOUNT, getAccount());
startActivity(i);
-
}
+
} else {
if (!operation.transferWasRequested()) {
Toast msg = Toast.makeText(this, ErrorMessageAdapter.getErrorCauseMessage(result,
operation, getResources()), Toast.LENGTH_LONG);
msg.show();
}
+ invalidateOptionsMenu();
}
}