diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java index a927d54d..8b7ccd60 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java @@ -4,6 +4,8 @@ import android.content.Intent; import android.content.SharedPreferences; import android.net.Uri; import android.os.Bundle; +import android.view.Menu; +import android.view.MenuInflater; import android.widget.Toast; import com.google.android.material.bottomnavigation.BottomNavigationView; @@ -86,6 +88,7 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF initialFragmentTransaction.commit(); bottomNavigation = findViewById(R.id.main_bottom_navigation); + if (sessionManager.isLoggedIn()) bottomNavigation.inflateMenu(R.menu.bottom_navigation_logged_in); bottomNavigation.setOnNavigationItemSelectedListener(menuItem -> { FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); switch (menuItem.getItemId()) { @@ -236,6 +239,12 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF sectionsPagerAdapter.removeFragment(2); else if (sessionManager.isLoggedIn() && sectionsPagerAdapter.getCount() == 2) sectionsPagerAdapter.addFragment(UnreadFragment.newInstance(3), "UNREAD"); + if (!sessionManager.isLoggedIn() && bottomNavigation.getMenu().size() > 2) { + bottomNavigation.getMenu().removeItem(R.id.action_shoutbox); + bottomNavigation.getMenu().removeItem(R.id.action_unread); + } else if (sessionManager.isLoggedIn() && bottomNavigation.getMenu().size() < 4) { + bottomNavigation.inflateMenu(R.menu.bottom_navigation_logged_in); + } } //-------------------------------FragmentPagerAdapter END------------------------------------------- diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/shoutbox/ShoutAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/shoutbox/ShoutAdapter.java index ef4ec164..80d91fae 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/shoutbox/ShoutAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/shoutbox/ShoutAdapter.java @@ -57,6 +57,7 @@ public class ShoutAdapter extends CustomRecyclerView.Adapter { Intent intent = new Intent(context, ProfileActivity.class); Bundle extras = new Bundle(); diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index c823abbc..8277e571 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -30,6 +30,6 @@ android:background="@color/primary" app:itemIconTint="@color/bottom_navigation_selector" app:itemTextColor="@color/bottom_navigation_selector" - app:menu="@menu/bottom_navigation" + app:menu="@menu/bottom_navigation_basic" app:labelVisibilityMode="labeled"/> diff --git a/app/src/main/res/menu/bottom_navigation.xml b/app/src/main/res/menu/bottom_navigation_basic.xml similarity index 56% rename from app/src/main/res/menu/bottom_navigation.xml rename to app/src/main/res/menu/bottom_navigation_basic.xml index 1fabf1d1..2ec0c775 100644 --- a/app/src/main/res/menu/bottom_navigation.xml +++ b/app/src/main/res/menu/bottom_navigation_basic.xml @@ -9,13 +9,4 @@ android:id="@+id/action_forum" android:icon="@drawable/ic_forum_white_24dp" android:title="@string/forum" /> - - - \ No newline at end of file diff --git a/app/src/main/res/menu/bottom_navigation_logged_in.xml b/app/src/main/res/menu/bottom_navigation_logged_in.xml new file mode 100644 index 00000000..5884a579 --- /dev/null +++ b/app/src/main/res/menu/bottom_navigation_logged_in.xml @@ -0,0 +1,11 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/xml/app_preferences.xml b/app/src/main/res/xml/app_preferences.xml index 7351616c..a0e3f98e 100644 --- a/app/src/main/res/xml/app_preferences.xml +++ b/app/src/main/res/xml/app_preferences.xml @@ -3,7 +3,7 @@ - --> - - - -