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

View File

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