From: Andy Scherzinger Date: Thu, 20 Aug 2015 11:50:44 +0000 (+0200) Subject: Merge branch 'material_toolbar' of https://github.com/owncloud/android into material_... X-Git-Tag: beta-20151128~7^2~40 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/d24b396d54ffd926c18cfb13687de3164ca80bc5?ds=inline;hp=-c Merge branch 'material_toolbar' of https://github.com/owncloud/android into material_buttons --- d24b396d54ffd926c18cfb13687de3164ca80bc5 diff --combined src/com/owncloud/android/ui/activity/FileActivity.java index 154aa7d6,f1508c28..80e9129f --- a/src/com/owncloud/android/ui/activity/FileActivity.java +++ b/src/com/owncloud/android/ui/activity/FileActivity.java @@@ -315,12 -315,26 +315,26 @@@ public class FileActivity extends AppCo super.onBackPressed(); } + /** + * checks if the drawer exists and is opened. + * + * @return true if the drawer is open, else false + */ 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(){ @@@ -349,7 -363,12 +363,7 @@@ // } // 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); @@@ -416,21 -435,6 +430,21 @@@ } /** + * 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.