From 5f1c6ee13481fa4f88137248be35c380611cb8cc Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Thu, 24 Mar 2016 14:27:29 +0100 Subject: [PATCH] split toolbar content method --- .../android/ui/activity/ToolbarActivity.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/com/owncloud/android/ui/activity/ToolbarActivity.java b/src/com/owncloud/android/ui/activity/ToolbarActivity.java index b35bf556d3..a41cfeabef 100644 --- a/src/com/owncloud/android/ui/activity/ToolbarActivity.java +++ b/src/com/owncloud/android/ui/activity/ToolbarActivity.java @@ -71,9 +71,22 @@ public class ToolbarActivity extends AppCompatActivity { title = chosenFile.getFileName(); } + updateActionBarTitleAndHomeButtonByString(title); + } + + /** + * Updates title bar and home buttons (state and icon). + */ + protected void updateActionBarTitleAndHomeButtonByString(String title) { + String titleToSet = getString(R.string.app_name); // default + + if (title != null) { + titleToSet = title; + } + // set the chosen title ActionBar actionBar = getSupportActionBar(); - actionBar.setTitle(title); + actionBar.setTitle(titleToSet); // also as content description View actionBarTitleView = getWindow().getDecorView().findViewById( @@ -81,7 +94,7 @@ public class ToolbarActivity extends AppCompatActivity { ); // TODO remove legacy code if (actionBarTitleView != null) { // it's null in Android 2.x - actionBarTitleView.setContentDescription(title); + actionBarTitleView.setContentDescription(titleToSet); } // set home button properties