diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/activities/MainActivity.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/activities/MainActivity.java index fc12c80..f713319 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/ui/activities/MainActivity.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/activities/MainActivity.java @@ -196,7 +196,7 @@ public class MainActivity extends AppCompatActivity implements //Get action id int id = item.getItemId(); - //To go backward + //To toggle drawer if (id == android.R.id.home) { toggleDrawer(); return true; @@ -208,17 +208,6 @@ public class MainActivity extends AppCompatActivity implements return true; } - //To display the personal page of the user - if (id == R.id.action_open_user_page) { - openUserPage(AccountUtils.getID(MainActivity.this)); - return true; - } - - //To display the list of friends - if (id == R.id.action_friends_list) { - openFriendsFragment(); - return true; - } //To open settings fragment if (id == R.id.action_settings) { @@ -251,6 +240,7 @@ public class MainActivity extends AppCompatActivity implements */ void init_drawer() { + assert getSupportActionBar() != null; getSupportActionBar().setDisplayHomeAsUpEnabled(true); mDrawer = findViewById(R.id.drawer_layout); @@ -274,7 +264,36 @@ public class MainActivity extends AppCompatActivity implements @Override public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) { - return false; + int id = menuItem.getItemId(); + + //Notification fragment + if(id == R.id.action_notifications){ + openNotificationsFragment(); + } + + //Friends list + else if(id == R.id.action_friendslist){ + openFriendsFragment(); + } + + //User personal page + else if(id == R.id.action_personal_page){ + openUserPage(new AccountUtils(this).get_current_user_id()); + } + + //Latest posts + else if(id == R.id.action_latest_posts){ + openLatestPostsFragment(); + } + + //Conversations fragment + else if(id == R.id.action_conversations) { + openConversationsListFragment(); + } + + + mDrawer.closeDrawer(GravityCompat.START); + return true; } diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/ConversationFragment.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/ConversationFragment.java index 3f142ed..60888c1 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/ConversationFragment.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/ConversationFragment.java @@ -13,7 +13,6 @@ import android.util.ArrayMap; import android.util.Log; import android.view.KeyEvent; import android.view.LayoutInflater; -import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.EditText; @@ -304,9 +303,8 @@ public class ConversationFragment extends Fragment //Update the bottom navigation menu ((MainActivity) getActivity()) - .setSelectedNavigationItem(R.id.main_bottom_navigation_conversations); + .setSelectedNavigationItem(R.id.action_conversations); - ((MainActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); //Check for conversation information if(conversationInfo == null){ @@ -337,7 +335,6 @@ public class ConversationFragment extends Fragment refreshRunnable.quitSafely(); - ((MainActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(false); } @Override diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/ConversationsListFragment.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/ConversationsListFragment.java index 8ff9913..1aa2292 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/ConversationsListFragment.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/ConversationsListFragment.java @@ -156,7 +156,7 @@ public class ConversationsListFragment extends Fragment implements AdapterView.O //Update the bottom navigation menu ((MainActivity) getActivity()) - .setSelectedNavigationItem(R.id.main_bottom_navigation_conversations); + .setSelectedNavigationItem(R.id.action_conversations); } /** diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/FriendsListFragment.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/FriendsListFragment.java index 9f0c424..3591c76 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/FriendsListFragment.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/FriendsListFragment.java @@ -170,7 +170,7 @@ public class FriendsListFragment extends Fragment //Update the bottom navigation menu ((MainActivity) getActivity()) //.setSelectedNavigationItem(R.id.main_bottom_navigation_friends_list); - .setSelectedNavigationItem(R.id.main_bottom_navigation_me_view); + .setSelectedNavigationItem(R.id.action_latest_posts); //Refresh the friends list refresh_friend_list(); diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/LatestPostsFragment.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/LatestPostsFragment.java index 176b5c3..326b671 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/LatestPostsFragment.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/LatestPostsFragment.java @@ -112,7 +112,7 @@ public class LatestPostsFragment extends Fragment //Update the bottom navigation menu ((MainActivity) getActivity()) - .setSelectedNavigationItem(R.id.main_bottom_navigation_me_view); + .setSelectedNavigationItem(R.id.action_latest_posts); //Refresh the list of posts of the user refresh_posts_list(); diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/NotificationsFragment.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/NotificationsFragment.java index e091dc9..3aa0344 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/NotificationsFragment.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/NotificationsFragment.java @@ -3,7 +3,6 @@ package org.communiquons.android.comunic.client.ui.fragments; import android.app.AlertDialog; import android.support.annotation.NonNull; import android.support.v4.app.Fragment; -import android.content.Context; import android.content.DialogInterface; import android.os.AsyncTask; import android.os.Bundle; @@ -141,7 +140,7 @@ public class NotificationsFragment extends Fragment implements View.OnCreateCont //Update the bottom navigation menu ((MainActivity) getActivity()) - .setSelectedNavigationItem(R.id.main_bottom_navigation_notif); + .setSelectedNavigationItem(R.id.action_notifications); //Get user page opener mUserPageOpener = (onOpenUsersPageListener) getActivity(); diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/UpdateConversationFragment.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/UpdateConversationFragment.java index fb33d53..6b5a05b 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/UpdateConversationFragment.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/UpdateConversationFragment.java @@ -232,7 +232,7 @@ public class UpdateConversationFragment extends Fragment { //Update title and dock ((MainActivity) getActivity()).setSelectedNavigationItem( - R.id.main_bottom_navigation_conversations); + R.id.action_conversations); //Set the adapted title if(current_action == ACTION_CREATE_CONVERSATION) diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/UserAccessDeniedFragment.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/UserAccessDeniedFragment.java index 089f319..cd33204 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/UserAccessDeniedFragment.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/UserAccessDeniedFragment.java @@ -153,7 +153,7 @@ public class UserAccessDeniedFragment extends Fragment implements View.OnClickLi //Update activity dock ((MainActivity) getActivity()) - .setSelectedNavigationItem(R.id.main_bottom_navigation_me_view); + .setSelectedNavigationItem(R.id.action_latest_posts); //Check if it is required to fetch user information if(mUserInfo == null){ diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/UserPageFragment.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/UserPageFragment.java index 64de9f8..a0596e5 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/UserPageFragment.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/UserPageFragment.java @@ -7,7 +7,6 @@ import android.os.AsyncTask; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.design.widget.TabLayout; -import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.view.ViewPager; import android.view.LayoutInflater; import android.view.View; @@ -178,7 +177,7 @@ public class UserPageFragment extends Fragment { //Update activity menu dock ((MainActivity) getActivity()).setSelectedNavigationItem( - R.id.main_bottom_navigation_me_view); + R.id.action_latest_posts); //Initialize view pager FragmentPagerBaseAdapter adapter = new FragmentPagerBaseAdapter(getChildFragmentManager()); diff --git a/app/src/main/res/drawable/ic_sync_black_24dp.xml b/app/src/main/res/drawable/ic_sync_black_24dp.xml new file mode 100644 index 0000000..2aef437 --- /dev/null +++ b/app/src/main/res/drawable/ic_sync_black_24dp.xml @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/app/src/main/res/menu/activity_main_drawer.xml b/app/src/main/res/menu/activity_main_drawer.xml index e245adc..5005fb1 100644 --- a/app/src/main/res/menu/activity_main_drawer.xml +++ b/app/src/main/res/menu/activity_main_drawer.xml @@ -2,32 +2,28 @@ + android:icon="@drawable/ic_notif" /> + android:id="@+id/action_personal_page" + android:title="@string/action_personal_page" + android:icon="@drawable/perm_group_personal_info" /> + android:id="@+id/action_latest_posts" + android:title="@string/action_latest_posts" + android:icon="@drawable/ic_sync_black_24dp" /> + android:icon="@drawable/ic_menu_conversations" /> \ No newline at end of file diff --git a/app/src/main/res/menu/main_menu.xml b/app/src/main/res/menu/main_menu.xml index b6d3342..c65ec15 100644 --- a/app/src/main/res/menu/main_menu.xml +++ b/app/src/main/res/menu/main_menu.xml @@ -7,16 +7,6 @@ android:id="@+id/action_search_user" android:title="@string/main_menu_search_user"/> - - - - - - J\'aime Liste d\'amis Notifications - Utilisateur + Fil d\'actualité Nouveau commentaire Nouveau post… Non diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b234a2a..18fa77f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -95,7 +95,7 @@ Private conversation Could not get a private conversation ! Loading… - User + Latest posts Couldn\'t get user posts ! public friends @@ -199,4 +199,5 @@ Navigation header Open navigation drawer Close navigation drawer + My Page