Add document name in toolbar

This commit is contained in:
Xsims 2023-01-22 15:09:24 +01:00 committed by Daniel Micay
parent 7f59118453
commit c6fb2aceda
1 changed files with 10 additions and 0 deletions

View File

@ -440,6 +440,15 @@ public class PdfViewer extends AppCompatActivity implements LoaderManager.Loader
return mPasswordPromptFragment;
}
private void setToolbarTitleWithDocumentName() {
String documentName = getCurrentDocumentName();
if (documentName != null && !documentName.isEmpty()) {
getSupportActionBar().setTitle(documentName);
} else {
getSupportActionBar().setTitle(R.string.app_name);
}
}
@Override
protected void onResume() {
super.onResume();
@ -471,6 +480,7 @@ public class PdfViewer extends AppCompatActivity implements LoaderManager.Loader
@Override
public void onLoadFinished(@NonNull Loader<List<CharSequence>> loader, List<CharSequence> data) {
mDocumentProperties = data;
setToolbarTitleWithDocumentName();
LoaderManager.getInstance(this).destroyLoader(DocumentPropertiesLoader.ID);
}