4646import javax .inject .Inject ;
4747
4848import androidx .annotation .NonNull ;
49+ import androidx .annotation .Nullable ;
4950import androidx .annotation .StringRes ;
5051import androidx .appcompat .app .ActionBar ;
5152import androidx .appcompat .widget .AppCompatSpinner ;
@@ -205,27 +206,22 @@ public String getActionBarTitle(OCFile chosenFile, boolean isRoot) {
205206 return getActionBarRootTitle ();
206207 }
207208
208- if (chosenFile .isFolder ()) {
209- return fileDataStorageManager .getFilenameConsideringOfflineOperation (chosenFile );
210- }
211-
212- long parentId = chosenFile .getParentId ();
213- OCFile parentFile = fileDataStorageManager .getFileById (parentId );
214- if (parentFile == null ) {
215- return "" ;
216- }
209+ return getActionBarTitleFromFile (chosenFile );
210+ }
217211
218- return fileDataStorageManager .getFilenameConsideringOfflineOperation (parentFile );
212+ private String getActionBarTitleFromFile (OCFile file ) {
213+ // if offline rename operation already pointing same file, offline operation name will be used
214+ return fileDataStorageManager .getFilenameConsideringOfflineOperation (file );
219215 }
220216
221- protected void updateActionBarTitleAndHomeButton (OCFile chosenFile ) {
217+ protected void updateActionBarTitleAndHomeButton (OCFile file ) {
222218 if (mAppBar == null ) {
223219 return ;
224220 }
225221
226222 final OCFileDepth currentDirDepth = getCurrentDirDepth ();
227- final boolean isRoot = isRoot (chosenFile ) || currentDirDepth == OCFileDepth .Root ;
228- final String title = getActionBarTitle (chosenFile , isRoot );
223+ final boolean isRoot = isRoot (file ) || currentDirDepth == OCFileDepth .Root ;
224+ final String title = getActionBarTitle (file , isRoot );
229225 updateActionBarTitleAndHomeButtonByString (title );
230226
231227 final boolean isToolbarStyleSearch = DrawerActivity .isToolbarStyleSearch ();
@@ -240,6 +236,20 @@ protected void updateActionBarTitleAndHomeButton(OCFile chosenFile) {
240236 }
241237 }
242238
239+ protected void updateActionBarForFile (@ Nullable OCFile file ) {
240+ if (mAppBar == null || file == null ) {
241+ return ;
242+ }
243+
244+ final String title = getActionBarTitleFromFile (file );
245+ updateActionBarTitleAndHomeButtonByString (title );
246+
247+ showHomeSearchToolbar (false );
248+ final var actionBar = getSupportActionBar ();
249+ if (actionBar != null ) {
250+ viewThemeUtils .files .themeActionBar (this , actionBar , title , false );
251+ }
252+ }
243253
244254 public void showSearchView () {
245255 if (isHomeSearchToolbarShow ) {
0 commit comments