From 850f759cde32f897db67c68abb737aee2788435c Mon Sep 17 00:00:00 2001 From: vanitasvitae Date: Thu, 29 Sep 2016 19:44:42 +0200 Subject: [PATCH] Fixed top/bottom menu entry population --- .../activity/MainActivity.java | 20 ++++++++++++------- .../fragment/DiasporaStreamFragment.java | 4 ++-- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/github/dfa/diaspora_android/activity/MainActivity.java b/app/src/main/java/com/github/dfa/diaspora_android/activity/MainActivity.java index 244bbc05..e9f12bfd 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/activity/MainActivity.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/activity/MainActivity.java @@ -192,7 +192,6 @@ public class MainActivity extends AppCompatActivity // Setup toolbar setSupportActionBar(toolbarTop); - getMenuInflater().inflate(R.menu.main__menu_bottom, toolbarBottom.getMenu()); toolbarBottom.setOnMenuItemClickListener(new ActionMenuView.OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { CustomFragment top = getTopFragment(); @@ -274,14 +273,14 @@ public class MainActivity extends AppCompatActivity * @param fragment Fragment to show */ protected void showFragment(CustomFragment fragment) { - AppLog.d(this, "showFragment()"); + AppLog.v(this, "showFragment()"); CustomFragment currentTop = (CustomFragment) fm.findFragmentById(R.id.fragment_container); if(currentTop == null || !currentTop.getFragmentTag().equals(fragment.getFragmentTag())) { - AppLog.d(this, "Fragment was not visible. Replace it."); + AppLog.v(this, "Fragment was not visible. Replace it."); fm.beginTransaction().addToBackStack(null).replace(R.id.fragment_container, fragment, fragment.getFragmentTag()).commit(); - fragment.onCreateBottomOptionsMenu(toolbarBottom.getMenu(), getMenuInflater()); + invalidateOptionsMenu(); } else { - AppLog.d(this, "Fragment was already visible. Do nothing."); + AppLog.v(this, "Fragment was already visible. Do nothing."); } } @@ -427,7 +426,7 @@ public class MainActivity extends AppCompatActivity @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { - AppLog.d(this, "onActivityResult(): "+requestCode); + AppLog.v(this, "onActivityResult(): "+requestCode); super.onActivityResult(requestCode, resultCode, data); } @@ -463,7 +462,7 @@ public class MainActivity extends AppCompatActivity AppLog.v(this, "Top Fragment is not null"); if(!top.onBackPressed()) { AppLog.v(this, "Top Fragment.onBackPressed was false"); - AppLog.d(this, "BackStackEntryCount: "+fm.getBackStackEntryCount()); + AppLog.v(this, "BackStackEntryCount: "+fm.getBackStackEntryCount()); if(fm.getBackStackEntryCount()>0) { fm.popBackStack(); } else { @@ -514,7 +513,14 @@ public class MainActivity extends AppCompatActivity @Override public boolean onCreateOptionsMenu(Menu menu) { AppLog.v(this, "onCreateOptionsMenu()"); + menu.clear(); getMenuInflater().inflate(R.menu.main__menu_top, menu); + toolbarBottom.getMenu().clear(); + getMenuInflater().inflate(R.menu.main__menu_bottom, toolbarBottom.getMenu()); + CustomFragment top = getTopFragment(); + if(top != null) { + top.onCreateBottomOptionsMenu(toolbarBottom.getMenu(), getMenuInflater()); + } return true; } diff --git a/app/src/main/java/com/github/dfa/diaspora_android/fragment/DiasporaStreamFragment.java b/app/src/main/java/com/github/dfa/diaspora_android/fragment/DiasporaStreamFragment.java index 8a86243c..2cd70e72 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/fragment/DiasporaStreamFragment.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/fragment/DiasporaStreamFragment.java @@ -85,7 +85,7 @@ public class DiasporaStreamFragment extends BrowserFragment { switch (requestCode) { case MainActivity.INPUT_FILE_REQUEST_CODE_NEW: case MainActivity.INPUT_FILE_REQUEST_CODE_OLD: - AppLog.d(this, "INPUT_FILE_REQUEST_CODE: "+requestCode); + AppLog.v(this, "INPUT_FILE_REQUEST_CODE: "+requestCode); onImageUploadResult(requestCode, resultCode, data); return; } @@ -243,7 +243,7 @@ public class DiasporaStreamFragment extends BrowserFragment { return false; } } - AppLog.d(this, "onOpenFileChooser"); + AppLog.v(this, "onOpenFileChooser"); if (imageUploadFilePathCallbackNew != null) imageUploadFilePathCallbackNew.onReceiveValue(null); imageUploadFilePathCallbackNew = filePathCallback; Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);