@@ -162,6 +162,8 @@ public class ReadArticleActivity extends AppCompatActivity {
162
162
private boolean onPageFinishedCallPostponedUntilResume ;
163
163
private boolean loadingFinished ;
164
164
165
+ private MaterialToolbar toolbar ;
166
+
165
167
@ Override
166
168
public void onCreate (Bundle savedInstanceState ) {
167
169
// not sure if it is relevant to WebView
@@ -188,14 +190,12 @@ public void onCreate(Bundle savedInstanceState) {
188
190
super .onCreate (savedInstanceState );
189
191
setContentView (R .layout .article );
190
192
191
- MaterialToolbar toolbar = findViewById (R .id .toolbar );
193
+ toolbar = findViewById (R .id .toolbar );
192
194
toolbar .setNavigationOnClickListener (v -> onBackPressed ());
193
- setSupportActionBar (toolbar );
194
195
195
196
if (fullscreenArticleView ) {
196
- ActionBar actionBar = getSupportActionBar ();
197
- if (actionBar != null ) {
198
- actionBar .hide ();
197
+ if (toolbar != null ) {
198
+ toolbar .setVisibility (View .GONE );
199
199
}
200
200
}
201
201
@@ -231,10 +231,19 @@ public void onCreate(Bundle savedInstanceState) {
231
231
annotationsEnabled = settings .isAnnotationsEnabled ();
232
232
onyxWorkaroundEnabled = settings .isOnyxWorkaroundEnabled ();
233
233
234
- setTitle (articleTitle );
234
+ toolbar . setTitle (articleTitle );
235
235
236
236
// article is loaded - update menu
237
- invalidateOptionsMenu ();
237
+ Log .d (TAG , "Creating the menu" );
238
+
239
+ toolbar .inflateMenu (R .menu .option_article );
240
+ Menu menu = toolbar .getMenu ();
241
+ if (article != null ) {
242
+ articleActionsHelper .initMenu (menu , article );
243
+ }
244
+ menu .findItem (R .id .menuTTS ).setChecked (ttsFragment != null );
245
+
246
+ toolbar .setOnMenuItemClickListener (this ::onOptionsItemSelected );
238
247
239
248
scrollView = findViewById (R .id .scroll );
240
249
scrollViewLastChild = scrollView .getChildAt (scrollView .getChildCount () - 1 );
@@ -306,23 +315,6 @@ protected void onDestroy() {
306
315
super .onDestroy ();
307
316
}
308
317
309
- @ Override
310
- public boolean onCreateOptionsMenu (Menu menu ) {
311
- super .onCreateOptionsMenu (menu );
312
-
313
- Log .d (TAG , "onCreateOptionsMenu() started" );
314
-
315
- getMenuInflater ().inflate (R .menu .option_article , menu );
316
-
317
- if (article != null ) {
318
- articleActionsHelper .initMenu (menu , article );
319
- }
320
-
321
- menu .findItem (R .id .menuTTS ).setChecked (ttsFragment != null );
322
-
323
- return true ;
324
- }
325
-
326
318
@ Override
327
319
public boolean onOptionsItemSelected (MenuItem item ) {
328
320
switch (item .getItemId ()) {
@@ -687,12 +679,11 @@ public void onHideCustomView() {
687
679
688
680
private void hideUi (boolean hide ) {
689
681
if (!fullscreenArticleView ) {
690
- ActionBar actionBar = getSupportActionBar ();
691
- if (actionBar != null ) {
682
+ if (toolbar != null ) {
692
683
if (hide ) {
693
- actionBar . hide ( );
684
+ toolbar . setVisibility ( View . GONE );
694
685
} else {
695
- actionBar . show ( );
686
+ toolbar . setVisibility ( View . VISIBLE );
696
687
}
697
688
}
698
689
}
0 commit comments