Made Drawer usable.

This commit is contained in:
Pierre HUBERT 2018-07-31 19:26:18 +02:00
parent 1ac52e6cfd
commit 7b31d25846
14 changed files with 63 additions and 53 deletions

View File

@ -196,7 +196,7 @@ public class MainActivity extends AppCompatActivity implements
//Get action id //Get action id
int id = item.getItemId(); int id = item.getItemId();
//To go backward //To toggle drawer
if (id == android.R.id.home) { if (id == android.R.id.home) {
toggleDrawer(); toggleDrawer();
return true; return true;
@ -208,17 +208,6 @@ public class MainActivity extends AppCompatActivity implements
return true; 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 //To open settings fragment
if (id == R.id.action_settings) { if (id == R.id.action_settings) {
@ -251,6 +240,7 @@ public class MainActivity extends AppCompatActivity implements
*/ */
void init_drawer() { void init_drawer() {
assert getSupportActionBar() != null;
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mDrawer = findViewById(R.id.drawer_layout); mDrawer = findViewById(R.id.drawer_layout);
@ -274,7 +264,36 @@ public class MainActivity extends AppCompatActivity implements
@Override @Override
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) { 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;
} }

View File

@ -13,7 +13,6 @@ import android.util.ArrayMap;
import android.util.Log; import android.util.Log;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.EditText; import android.widget.EditText;
@ -304,9 +303,8 @@ public class ConversationFragment extends Fragment
//Update the bottom navigation menu //Update the bottom navigation menu
((MainActivity) getActivity()) ((MainActivity) getActivity())
.setSelectedNavigationItem(R.id.main_bottom_navigation_conversations); .setSelectedNavigationItem(R.id.action_conversations);
((MainActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);
//Check for conversation information //Check for conversation information
if(conversationInfo == null){ if(conversationInfo == null){
@ -337,7 +335,6 @@ public class ConversationFragment extends Fragment
refreshRunnable.quitSafely(); refreshRunnable.quitSafely();
((MainActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(false);
} }
@Override @Override

View File

@ -156,7 +156,7 @@ public class ConversationsListFragment extends Fragment implements AdapterView.O
//Update the bottom navigation menu //Update the bottom navigation menu
((MainActivity) getActivity()) ((MainActivity) getActivity())
.setSelectedNavigationItem(R.id.main_bottom_navigation_conversations); .setSelectedNavigationItem(R.id.action_conversations);
} }
/** /**

View File

@ -170,7 +170,7 @@ public class FriendsListFragment extends Fragment
//Update the bottom navigation menu //Update the bottom navigation menu
((MainActivity) getActivity()) ((MainActivity) getActivity())
//.setSelectedNavigationItem(R.id.main_bottom_navigation_friends_list); //.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 the friends list
refresh_friend_list(); refresh_friend_list();

View File

@ -112,7 +112,7 @@ public class LatestPostsFragment extends Fragment
//Update the bottom navigation menu //Update the bottom navigation menu
((MainActivity) getActivity()) ((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 the list of posts of the user
refresh_posts_list(); refresh_posts_list();

View File

@ -3,7 +3,6 @@ package org.communiquons.android.comunic.client.ui.fragments;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
@ -141,7 +140,7 @@ public class NotificationsFragment extends Fragment implements View.OnCreateCont
//Update the bottom navigation menu //Update the bottom navigation menu
((MainActivity) getActivity()) ((MainActivity) getActivity())
.setSelectedNavigationItem(R.id.main_bottom_navigation_notif); .setSelectedNavigationItem(R.id.action_notifications);
//Get user page opener //Get user page opener
mUserPageOpener = (onOpenUsersPageListener) getActivity(); mUserPageOpener = (onOpenUsersPageListener) getActivity();

View File

@ -232,7 +232,7 @@ public class UpdateConversationFragment extends Fragment {
//Update title and dock //Update title and dock
((MainActivity) getActivity()).setSelectedNavigationItem( ((MainActivity) getActivity()).setSelectedNavigationItem(
R.id.main_bottom_navigation_conversations); R.id.action_conversations);
//Set the adapted title //Set the adapted title
if(current_action == ACTION_CREATE_CONVERSATION) if(current_action == ACTION_CREATE_CONVERSATION)

View File

@ -153,7 +153,7 @@ public class UserAccessDeniedFragment extends Fragment implements View.OnClickLi
//Update activity dock //Update activity dock
((MainActivity) getActivity()) ((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 //Check if it is required to fetch user information
if(mUserInfo == null){ if(mUserInfo == null){

View File

@ -7,7 +7,6 @@ import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout; import android.support.design.widget.TabLayout;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -178,7 +177,7 @@ public class UserPageFragment extends Fragment {
//Update activity menu dock //Update activity menu dock
((MainActivity) getActivity()).setSelectedNavigationItem( ((MainActivity) getActivity()).setSelectedNavigationItem(
R.id.main_bottom_navigation_me_view); R.id.action_latest_posts);
//Initialize view pager //Initialize view pager
FragmentPagerBaseAdapter adapter = new FragmentPagerBaseAdapter(getChildFragmentManager()); FragmentPagerBaseAdapter adapter = new FragmentPagerBaseAdapter(getChildFragmentManager());

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M12 4V1L8 5l4 4V6c3.31 0 6 2.69 6 6 0 1.01,-0.25 1.97,-0.7 2.8l1.46 1.46C19.54 15.03 20 13.57 20 12c0,-4.42,-3.58,-8,-8,-8zm0 14c-3.31 0,-6,-2.69,-6,-6 0,-1.01 0.25,-1.97 0.7,-2.8L5.24 7.74C4.46 8.97 4 10.43 4 12c0 4.42 3.58 8 8 8v3l4,-4,-4,-4v3z" />
</vector>

View File

@ -2,32 +2,28 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"> <menu xmlns:android="http://schemas.android.com/apk/res/android">
<item <item
android:id="@+id/main_bottom_navigation_notif" android:id="@+id/action_notifications"
android:title="@string/navigation_bottom_notif_item" android:title="@string/navigation_bottom_notif_item"
android:icon="@drawable/ic_notif" /> android:icon="@drawable/ic_notif" />
<item <item
android:id="@+id/main_bottom_navigation_friends_list" android:id="@+id/action_friendslist"
android:title="@string/navigation_bottom_friends_item" android:title="@string/navigation_bottom_friends_item"
android:icon="@drawable/ic_menu_allfriends" android:icon="@drawable/ic_menu_allfriends"
/> />
<item <item
android:id="@+id/main_bottom_navigation_users_view" android:id="@+id/action_personal_page"
android:title="@string/navigation_bottom_user_item" android:title="@string/action_personal_page"
android:icon="@drawable/perm_group_personal_info" android:icon="@drawable/perm_group_personal_info" />
android:visible="false" />
<item <item
android:id="@+id/main_bottom_navigation_me_view" android:id="@+id/action_latest_posts"
android:title="@string/navigation_bottom_user_item" android:title="@string/action_latest_posts"
android:icon="@drawable/perm_group_personal_info" android:icon="@drawable/ic_sync_black_24dp" />
/> <!--android:icon="@drawable/ic_menu_home"
android:title="@string/navigation_bottom_me_item"-->
<item <item
android:id="@+id/main_bottom_navigation_conversations" android:id="@+id/action_conversations"
android:title="@string/navigation_bottom_conversations_item" android:title="@string/navigation_bottom_conversations_item"
android:icon="@drawable/ic_menu_conversations" android:icon="@drawable/ic_menu_conversations" />
/>
</menu> </menu>

View File

@ -7,16 +7,6 @@
android:id="@+id/action_search_user" android:id="@+id/action_search_user"
android:title="@string/main_menu_search_user"/> android:title="@string/main_menu_search_user"/>
<!-- Open user page -->
<item
android:id="@+id/action_open_user_page"
android:title="@string/main_menu_personal_page"/>
<!-- Display friends list -->
<item
android:id="@+id/action_friends_list"
android:title="@string/main_menu_friends_list" />
<!-- Settings --> <!-- Settings -->
<item <item
android:id="@+id/action_settings" android:id="@+id/action_settings"

View File

@ -121,7 +121,7 @@
<string name="like_view_liking">J\'aime</string> <string name="like_view_liking">J\'aime</string>
<string name="main_menu_friends_list">Liste d\'amis</string> <string name="main_menu_friends_list">Liste d\'amis</string>
<string name="navigation_bottom_notif_item">Notifications</string> <string name="navigation_bottom_notif_item">Notifications</string>
<string name="navigation_bottom_user_item">Utilisateur</string> <string name="action_latest_posts">Fil d\'actualité</string>
<string name="new_comment_hint">Nouveau commentaire</string> <string name="new_comment_hint">Nouveau commentaire</string>
<string name="new_post_hint">Nouveau post…</string> <string name="new_post_hint">Nouveau post…</string>
<string name="popup_deletecomment_cancel">Non</string> <string name="popup_deletecomment_cancel">Non</string>

View File

@ -95,7 +95,7 @@
<string name="action_friends_start_private_conversation">Private conversation</string> <string name="action_friends_start_private_conversation">Private conversation</string>
<string name="err_get_private_conversation">Could not get a private conversation !</string> <string name="err_get_private_conversation">Could not get a private conversation !</string>
<string name="dialog_loading_msg">Loading…</string> <string name="dialog_loading_msg">Loading…</string>
<string name="navigation_bottom_user_item">User</string> <string name="action_latest_posts">Latest posts</string>
<string name="err_get_user_posts">Couldn\'t get user posts !</string> <string name="err_get_user_posts">Couldn\'t get user posts !</string>
<string name="post_visibility_public">public</string> <string name="post_visibility_public">public</string>
<string name="post_visibility_friends">friends</string> <string name="post_visibility_friends">friends</string>
@ -199,4 +199,5 @@
<string name="nav_header_desc">Navigation header</string> <string name="nav_header_desc">Navigation header</string>
<string name="navigation_drawer_open">Open navigation drawer</string> <string name="navigation_drawer_open">Open navigation drawer</string>
<string name="navigation_drawer_close">Close navigation drawer</string> <string name="navigation_drawer_close">Close navigation drawer</string>
<string name="action_personal_page">My Page</string>
</resources> </resources>