diff --git a/app/src/main/java/org/communiquons/android/comunic/client/MainActivity.java b/app/src/main/java/org/communiquons/android/comunic/client/MainActivity.java index 40145d0..1c236a7 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/MainActivity.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/MainActivity.java @@ -19,6 +19,7 @@ import org.communiquons.android.comunic.client.api.APIRequest; import org.communiquons.android.comunic.client.data.Account.Account; import org.communiquons.android.comunic.client.data.Account.AccountUtils; import org.communiquons.android.comunic.client.data.DatabaseHelper; +import org.communiquons.android.comunic.client.data.UsersInfo.GetUsersHelper; import org.communiquons.android.comunic.client.data.conversations.ConversationsListHelper; import org.communiquons.android.comunic.client.data.friendsList.FriendRefreshLoopRunnable; import org.communiquons.android.comunic.client.data.utils.UiUtils; @@ -37,7 +38,8 @@ import org.communiquons.android.comunic.client.fragments.UserPageFragment; */ public class MainActivity extends AppCompatActivity implements ConversationsListHelper.openConversationListener, - ConversationsListHelper.updateConversationListener { + ConversationsListHelper.updateConversationListener, + GetUsersHelper.onOpenUsersPageListener { /** * Debug tag @@ -272,7 +274,8 @@ public class MainActivity extends AppCompatActivity * * @param userID The ID of the user to open */ - void openUserPage(int userID){ + @Override + public void openUserPage(int userID){ //Prepare arguments Bundle args = new Bundle(); diff --git a/app/src/main/java/org/communiquons/android/comunic/client/data/friendsList/FriendUser.java b/app/src/main/java/org/communiquons/android/comunic/client/data/friendsList/FriendUser.java index 2c6e9f7..1813961 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/data/friendsList/FriendUser.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/data/friendsList/FriendUser.java @@ -66,4 +66,14 @@ public class FriendUser { public void setFriend(Friend friend) { this.friend = friend; } + + + /*** + * Get the ID of the user + * + * @return The id of the user + */ + public int get_user_id(){ + return userInfo.getId(); + } } diff --git a/app/src/main/java/org/communiquons/android/comunic/client/fragments/FriendsListFragment.java b/app/src/main/java/org/communiquons/android/comunic/client/fragments/FriendsListFragment.java index c1d76f6..068a745 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/fragments/FriendsListFragment.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/fragments/FriendsListFragment.java @@ -39,7 +39,8 @@ import java.util.ArrayList; * Created by pierre on 11/11/17. */ -public class FriendsListFragment extends Fragment { +public class FriendsListFragment extends Fragment + implements AdapterView.OnItemClickListener{ /** * Debug tag @@ -81,6 +82,11 @@ public class FriendsListFragment extends Fragment { */ private ConversationsListHelper.openConversationListener convOpener; + /** + * Users page opener + */ + private GetUsersHelper.onOpenUsersPageListener usersPageOpener; + /** * Friend adapter */ @@ -105,11 +111,13 @@ public class FriendsListFragment extends Fragment { //Cast activity to convOpener try { convOpener = (ConversationsListHelper.openConversationListener) getActivity(); + usersPageOpener = (GetUsersHelper.onOpenUsersPageListener) getActivity(); } catch (ClassCastException e){ e.printStackTrace(); throw new RuntimeException(getActivity().getClass().getName() + " must implement" + - "ConversationsListHelper.openConversationListener !"); + "ConversationsListHelper.openConversationListener " + + "and GetUsersHelper.onOpenUsersPageListener !"); } } @@ -214,6 +222,8 @@ public class FriendsListFragment extends Fragment { //Register the view for the context menu registerForContextMenu(listView); + + listView.setOnItemClickListener(this); } @Override @@ -366,4 +376,14 @@ public class FriendsListFragment extends Fragment { } + + @Override + public void onItemClick(AdapterView parent, View view, int position, long id) { + + //Get clicked user ID + int userID = friendsList.get(position).get_user_id(); + + //Open user page + usersPageOpener.openUserPage(userID); + } } diff --git a/app/src/main/java/org/communiquons/android/comunic/client/fragments/UserPageFragment.java b/app/src/main/java/org/communiquons/android/comunic/client/fragments/UserPageFragment.java index 82f6314..57dadd1 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/fragments/UserPageFragment.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/fragments/UserPageFragment.java @@ -12,7 +12,9 @@ import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; +import org.communiquons.android.comunic.client.MainActivity; import org.communiquons.android.comunic.client.R; +import org.communiquons.android.comunic.client.data.Account.AccountUtils; import org.communiquons.android.comunic.client.data.DatabaseHelper; import org.communiquons.android.comunic.client.data.ImageLoad.ImageLoadManager; import org.communiquons.android.comunic.client.data.UsersInfo.AdvancedUserInfo; @@ -152,9 +154,21 @@ public class UserPageFragment extends Fragment { //Save user informations userInfo = info; + //Set activity title + getActivity().setTitle(userInfo.getDisplayFullName()); + + //Update activity menu dock + if(AccountUtils.getID(getActivity()) == userID) + ((MainActivity) getActivity()).setSelectedNavigationItem( + R.id.main_bottom_navigation_me_view); + else + ((MainActivity) getActivity()).setSelectedNavigationItem( + R.id.main_bottom_navigation_users_view); + //Update user name and account image user_name.setText(userInfo.getDisplayFullName()); ImageLoadManager.remove(user_image); ImageLoadManager.load(getActivity(), userInfo.getAcountImageURL(), user_image); + } } diff --git a/app/src/main/res/drawable/perm_group_personal_info.png b/app/src/main/res/drawable/perm_group_personal_info.png new file mode 100644 index 0000000..13505a6 Binary files /dev/null and b/app/src/main/res/drawable/perm_group_personal_info.png differ diff --git a/app/src/main/res/menu/main_bottom_navigation.xml b/app/src/main/res/menu/main_bottom_navigation.xml index 0e86601..9b94b8e 100644 --- a/app/src/main/res/menu/main_bottom_navigation.xml +++ b/app/src/main/res/menu/main_bottom_navigation.xml @@ -6,6 +6,12 @@ android:icon="@drawable/ic_menu_allfriends" /> + + Private conversation Could not get a private conversation ! Loading… + User